I feel that the following assertion should be true, but it is not:
DateTime testDate = DateTime.now();
System.assertEquals('"' + testDate.format('yyyy-MM-dd\'T\'hh:mm:ss.SSS\'Z\'' + '"'), JSON.serialize(testDate));
I get the following error:
16:38:28.966 (2966802000)|FATAL_ERROR|System.AssertException: Assertion Failed: Expected: "2014-04-03T04:38:27.988Z", Actual: "2014-04-03T20:38:27.988Z"
Update: when using formatGMT I still get the error:
DateTime testDate = DateTime.now();
System.assertEquals('"' + testDate.formatGMT('yyyy-MM-dd\'T\'hh:mm:ss.SSS\'Z\'' + '"'), JSON.serialize(testDate));
16:51:32.228 (2228010000)|FATAL_ERROR|System.AssertException: Assertion Failed: Expected: "2014-04-03T08:51:31.274Z", Actual: "2014-04-03T20:51:31.274Z"