1

I'm making an API callout that returns a date/time in the following format:

"Thu May 8 1:21 PM EDT"

as well as a timestamp in the following format (millis since unix epoch):

"1399569719024"

Since these are both fairly common date formats, I'm wondering if Salesforce provides functions to convert this data into values that can be stored in a datetime field, or if I'll have to write some code to convert it? Thanks for your help!

3

looks like I was searching for the wrong terms earlier: searching for unix epoch conversion revealed this link:

Convert Date to milliseconds and milliseconds to Date

As well as this:

http://www.codetalks.in/2013/08/salesforce-apex-unix-time-stamp-datetime.html


EDIT: Oh, also, here's the documentation of the method that works directly with Unix millisecond timestamps

datetime.newInstance(Long)

Constructs a Datetime and initializes it to represent the specified number of milliseconds since January 1, 1970, 00:00:00 GMT.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.