+ Start a Discussion
William SymansWilliam Symans 

Issue with GMTFormat()

Happy New Year All! Strange issue that may be related to the New Year. I have an APEX integration to Amazon S3. It stopped working indicating that the date in the request is not yet valid. I checked it out and it looks like the formerly working integration is now sending 12/31/2018 as an expiration date. It appears to be related to gmtFormat dateTime function. I set up a test below and the results.

String iso8601date = system.now().formatGmt('YYYYMMdd\'T\'HHmmss\'Z\'');
system.debug('formatGMT ' + iso8601date);
11:43:25:001 USER_DEBUG [2]|DEBUG|formatGMT 20181231T164325Z

DateTime iso8601date2 = system.now();
system.debug('not formatted ' + string.valueof(iso8601date2));
11:43:25:002 USER_DEBUG [5]|DEBUG|not formatted 2017-12-31 08:43:25 

Note: the user is PST so the times are the same.

Anyone else seeing this behavior? This is in a dev org, but I tried in my prod org and seemed to get the same results.

 
Eric JJ van HorssenEric JJ van Horssen
https://salesforce.stackexchange.com/questions/103656/issue-with-salesforce-datetime-formatgmt-method

YYYY, returns the Year of the current week
yyyyy, returns just the year
William SymansWilliam Symans
Thank you so much. Will try that out.
Eric JJ van HorssenEric JJ van Horssen
I suppose the user, looking at being in PST, also has his locale set to US?

Most European locales have Monday as the first day of the week, which would not have caused an issue this year. ;-)

Happy New Year and carefull with the Fireworks!