cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Thank you Evigeny for helping.

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

Answers (2)

Answers (2)

0 Kudos

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.

former_member190293
Active Contributor
0 Kudos

Hi Raghava!

Regards, Evgeniy.

0 Kudos

Thanks, Evgeniy. This code is perfectly working fine.

former_member190293
Active Contributor
0 Kudos

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

former_member194786
Active Contributor
0 Kudos

Adding to what Evgeniy has already provided, you may need to multiply by 1000, if the JSON timestamp is in milliseconds.