XStream
  1. XStream
  2. XSTR-556

serialized java.util.Dates have ambiguous timezones

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.4
    • Component/s: Converters
    • Labels:
      None

      Description

      The serialized Dates created by the standard DateConverter have ambiguous 3-letter timezones. This may result in wrong dates when the data deserialized under a different default timezone than the timezone they were serialized in.

      DateConverter uses the datetime pattern "yyyy-MM-dd HH:mm:ss.S z" which creates ambiguous 3-letter timezones (e.g. EST). When e.g. a date is serialized in Australian eastern time (EST) and deserialized in Amerian eastern time (also EST), the timestamp changes!

      Test case:

      String pattern = "yyyy-MM-dd HH:mm:ss.S z";
      TimeZone.setDefault(TimeZone.getTimeZone("Australia/Brisbane"));
      Date date = new Date(0);
      System.out.println(date.getTime());
      String s = new SimpleDateFormat(pattern).format(date);
      System.out.println(s);
      TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
      System.out.println(new SimpleDateFormat(pattern).parse(s).getTime());

      prints:
      0
      1970-01-01 10:00:00.0 EST
      54000000

        People

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

          Dates

          • Created:
            Updated:
            Resolved: