Details
-
Type: Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.1.3
-
Component/s: None
-
Labels:None
Description
To serialize and deserialize a Date with ISO8601 the time zone must match, otherwise the time shifts. The current implementation ignores the current TimeZone of the JDK completely:
public void testSavedTimeIsInUTC()
{ TimeZone.setDefault(TimeZone.getTimeZone("EST")); Date in = new Date(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); String jdkConverted = format.format(in); String iso8601 = jdkConverted.substring(0, jdkConverted.length() - 2) + ":" + jdkConverted.substring(jdkConverted.length() - 2); assertEquals(iso8601, converter.toString(in)); }Since the ISO8601 writes the date in UTC, the resulting string should be the same. Unfortunately it is the UTC representation of the default TimeZone of the computer.
Fixed by introducing a time zone aware ISO8601GregorianCalendarConverter as new base class for ISO8601DateConverter.