There is a webservice which I'm trying to integrate in Salesforce. The webservice returns a date time in format like this
/Date(1569301200000-0500)/
I believe this is Unix Timestamp, and we can convert it into Apex Datetime using Datetime.newInstance( Long.valueOf( '1569301200000' ) )
But I'm missing the extra -0500
also in here and I'm not able to compensate for this. Can someone guide me how to accurately read the datetime in APEX with this format?
Best Answer
Refer to this document
You can use this online datetime converter to check the date and time.
1569301200000-0500
is not Unix epoch but only1569301200000
is, and it converts to below:Also
Datetime.newInstance( Long.valueOf( '1569301200000' ) )
returns 2019-09-24 05:00:00Perhaps
0500
is just indicating that its 5am in GMT or else-0500
could be time correction to get local time for which you can use DateTime.addHours or DateTime.addMinutes. In any case you need to get clarification from the webservice developers regarding what is 0500