XStream
  1. XStream
  2. XSTR-247

ISO8601DateConverter ignores current TimeZone

    Details

    • Type: Bug Bug
    • Status: Closed 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.

        People

        • Assignee:
          Unassigned
          Reporter:
          Jörg Schaible
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: