You need to sign in to do that
Don't have an account?
John Brodrick
Bug in Datetime.newInstance(long)?
Hello All-
Maybe I'm doing something wrong here, but I am not getting the expected result. I am trying to convert a UNIX timestamp to a DateTime object in Salesforce and the times that I am getting in the DateTime objects are way off. Here are 3 examples:
System.debug(Datetime.newInstance(1426982400L).format());
Debug Log: 1/17/1970 4:23 AM
Expected: Sun, 22 Mar 2015 00:00:00 GMT
System.debug(Datetime.newInstance(1490140800L).format());
Debug Log: USER_DEBUG|[197]|DEBUG|1/17/1970 9:55 PM
Expected: Wed, 22 Mar 2017 00:00:00 GMT
System.debug(Datetime.newInstance(4645814400L).format());
Debug Log: USER_DEBUG|[198]|DEBUG|2/23/1970 10:30 AM
Expected: Mon, 22 Mar 2117 00:00:00 GMT
Again maybe there is something I am missing here.
Thanks,
John
Maybe I'm doing something wrong here, but I am not getting the expected result. I am trying to convert a UNIX timestamp to a DateTime object in Salesforce and the times that I am getting in the DateTime objects are way off. Here are 3 examples:
System.debug(Datetime.newInstance(1426982400L).format());
Debug Log: 1/17/1970 4:23 AM
Expected: Sun, 22 Mar 2015 00:00:00 GMT
System.debug(Datetime.newInstance(1490140800L).format());
Debug Log: USER_DEBUG|[197]|DEBUG|1/17/1970 9:55 PM
Expected: Wed, 22 Mar 2017 00:00:00 GMT
System.debug(Datetime.newInstance(4645814400L).format());
Debug Log: USER_DEBUG|[198]|DEBUG|2/23/1970 10:30 AM
Expected: Mon, 22 Mar 2117 00:00:00 GMT
Again maybe there is something I am missing here.
Thanks,
John
Cheers!
Vladimir
All Answers
Cheers!
Vladimir