Question

Convert milliseconds to a date

Hi,

Is there any OOTB function available to Convert milliseconds to a date/timestamp?

Regards,

AK

***Edited by Moderator: Lochan to update platform capability tags***

Correct Answer
July 25, 2019 - 4:46am

Hi,

There is a function available MilliSecondsToDate in CPMSocial library. 

If you dont have CS framework, Here's the javacode

Long d=Long.parseLong(timeMilli, 10);
java.util.Date d1=new Date(d);
//String dateReturned=PRDateFormat.format("en-US", "EST", "dd-MMM-yyyy", d1);

String dateReturned=PRDateFormat.format(null, "GMT", PRDateFormat.DEFAULT_DATETIME_FULL, d1);
return dateReturned;

Comments

Keep up to date on this post and subscribe to comments

Pega
July 25, 2019 - 4:46am

Hi,

There is a function available MilliSecondsToDate in CPMSocial library. 

If you dont have CS framework, Here's the javacode

Long d=Long.parseLong(timeMilli, 10);
java.util.Date d1=new Date(d);
//String dateReturned=PRDateFormat.format("en-US", "EST", "dd-MMM-yyyy", d1);

String dateReturned=PRDateFormat.format(null, "GMT", PRDateFormat.DEFAULT_DATETIME_FULL, d1);
return dateReturned;

July 25, 2019 - 8:08am

Thank you