Skip to Content

Converting Date format from Systemdate to Epoch/UNIX timestamp(1513774271000) in SAP PI?

Hi Experts,

I have a requirement in one of the mapping, Date is coming from the Source system as "sy-datum" let say for example "20/12/2017 12/51/11", this date format would be convert into Json timestamp like /Date(1513774271000)/.

I am not aware how to normal datetime stamp get converted into 1513774271000(Epoch timestamp).

Can anybody help to write UDF for this?

Thank you, Raghava.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Dec 29, 2017 at 09:56 AM

    Thank you Evigeny for helping.

    https://answers.sap.com/comments/392403/view.html

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 21, 2017 at 12:04 PM

    Hi Raghava!

    String dateString = "20/12/2017 12:51:11";
    long datetime = (new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")).parse(dateString).getTime();

    Regards, Evgeniy

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 28, 2017 at 09:46 AM

    Hi Evgeniy,

    Thank you for a quick reply, I have tried to implement the code as you suggested. But I am getting an error.

    Please the find the code

    Please suggest.


    error.png (16.2 kB)
    code.png (11.0 kB)
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.