tracker issue : CF-4202189

select a category, or use search below
(searches all categories and all time range)

[ANeff] Bug for: WDDX (correct) vs JSON (incorrect) wrt DateTime

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/DesignLimitation

Reporter/Name(from Bugbase): Aaron Neff / ()

Created: 04/28/2018

Components: Serialization

Versions: 2018

Failure Type: Data Loss

Found In Build/Fixed In Build: 2018.0.01.308605 (PreRelease) /

Priority/Frequency: Normal / Most users will encounter

Locale/System: / Platforms All

Vote Count: 0

Issue: WDDX (correct) vs JSON (incorrect) wrt DateTime


WDDX gets it right (maintains UTC offset and deserializses back to DateTime):
  myDateTime = createDate(2018,1,1)
  cfwddx(action="cfml2wddx", input=myDateTime, output="myDateTimeWDDX")
  cfwddx(action="wddx2cfml", input=myDateTimeWDDX, output="myDateTimeFromWDDX")
  writeOutput(myDateTimeWDDX & ' | ' & myDateTimeFromWDDX.getClass().getName())

Actual and Expected Result: 2018-01-01T00:00:00-05:00 | coldfusion.runtime.OleDateTime

JSON gets it wrong (loses UTC offset and deserializes back to String):
  myDateTime = createDate(2018,1,1)
  myDateTimeJSON = serializeJSON(myDateTime)
  myDateTimeFromJSON = deserializeJSON(myDateTimeJSON)
  writeOutput(myDateTimeJSON & ' | ' & myDateTimeFromJSON.getClass().getName())

Actual Result: "January, 01 2018 00:00:00" | java.lang.String

Expected Result: 2018-01-01T00:00:00-05:00 | coldfusion.runtime.OleDateTime

Note: Since Aether's fixing JSON for Numeric, it should also fix JSON for DateTime.

Note: There is data loss when a serializeJSON()'d datetime moves between 2 systems having different OS/JVM time zones. B/c, currently the systems assume the datetime is in _their_ time zone.



Hi Adobe, I see this is currently ToFix/HaveNewInfo. This ticket is 2-part: 1) SerializeJSON(DateTime) should serialize DateTime to ISO8601 format 2) DeserializeJSON({AnISO8601String}) should deserialize an ISO8601 string to DateTime Can you please clarify if both are being fixed? Thanks!, -Aaron
Comment by Aaron N.
27677 | May 05, 2018 01:39:45 AM GMT
Will not be fixing this since, - During serialization, dates are converted to the following format explicitly - "October, 03 2014 15:01:00". We have arrived on this format after a handful of bugs were logged for date serialization inconsistencies. Changing to a different format now will also cause backward compatibility issues.  - During deserialization, datatypes are not predicted. Will not be attempting a cast to date as an exception. 
Comment by Immanuel N.
27726 | May 09, 2018 10:24:58 AM GMT
Hi Immanuel, But JSON serialization/deserialization of DateTime is broken b/c the time zone can be lost when deserializing on another system. CF fixed issues for numbers and booleans but can't for DateTime? How about a `THIS.serialization.preserveDateTime` per-app setting, to get the correct behavior, please? Thanks!, -Aaron
Comment by Aaron N.
27752 | May 11, 2018 09:20:15 AM GMT
"can be lost" should've been "can be wrong"
Comment by Aaron N.
27753 | May 11, 2018 09:25:00 AM GMT