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 comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

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

    Thank you Evigeny for helping.

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

    Add comment
    10|10000 characters needed characters exceeded

  • 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 comment
    10|10000 characters needed characters exceeded

  • 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.

    Add comment
    10|10000 characters needed characters exceeded