cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert date in CPI using groovy script

0 Kudos
5,063

Hello Team,

I have a requirement where I need to send the date in 10 digit number like "1643611297" through SAP CPI.

Can anyone please suggest me if there is any groovy script to convert date from format like "YYYY-MM-DD HH:mm:ss.SSS" to "1643611297"?

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

rohitjain3009
Newcomer
0 Kudos

//Use class

import java.util.Date;

Date oldDate = Date.parse('yyyy-MM-ddHH:mm:ss.SSS', yourDateVariable);

String newDateAsString = oldDate.format("yyyyMMddHH");

https://www.tutorialspoint.com/java/java_date_time.htm

0 Kudos

Hello Rohit,

Thank you for your reply.

It is working fine now for me and I have used epoc time converter to convert the date.

Thanks