Tuesday, February 2, 2016

Get Full DateTime Format (GMT) in Apex

To get the full DateTime format in GMT such that it's compatible with Apex methods like JSON.deserialize(),  the most accurate method is to call DateTime.formatGmt().

For comparison, below are some other alternatives for generating similar String values for a DateTime object.