XStream
  1. XStream
  2. XSTR-508

serialize/deserialize subtracts 1 day from Joda-Time LocalDate instances.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.3.1
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      Sun JDK 1.6

      Description

      =========== %< ============
      final LocalDate ld0 = new LocalDate(2008, 07, 03);
      final XStream xs = new XStream();
      final String xml0 = xs.toXML(ld0);
      final LocalDate ld1 = (LocalDate) xs.fromXML(xml0);
      final String xml1 = xs.toXML(ld1);
      final LocalDate ld2 = (LocalDate) xs.fromXML(xml1);

      LocalDate ld1s = null;
      LocalDate ld2s = null;
      try

      { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(ld0); oos.close(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); ld1s = (LocalDate)ois.readObject(); ois.close(); baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(ld1s); oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); ld2s = (LocalDate)ois.readObject(); ois.close(); }

      catch (Exception e)

      { // nothing }

      System.out.println(ld0.toString() + '\n' + xml0 + '\n'
      + ld1 + " (" + ld1s + ")\n" + xml1 + '\n'
      + ld2 + " (" + ld2s + ")\n");
      =========== %< ============

      For me it prints:

      2008-07-03
      <org.joda.time.LocalDate>
      <iLocalMillis>1215043200000</iLocalMillis>
      <iChronology class="org.joda.time.chrono.ISOChronology"
      resolves-to="org.joda.time.chrono.ISOChronology$Stub" serialization="custom">
      <org.joda.time.chrono.ISOChronology_-Stub>
      <org.joda.time.tz.FixedDateTimeZone
      resolves-to="org.joda.time.DateTimeZone$Stub"/>
      </org.joda.time.chrono.ISOChronology_-Stub>
      </iChronology>
      </org.joda.time.LocalDate>
      2008-07-02 (2008-07-03)
      <org.joda.time.LocalDate>
      <iLocalMillis>1215043200000</iLocalMillis>
      <iChronology class="org.joda.time.chrono.ISOChronology"
      resolves-to="org.joda.time.chrono.ISOChronology$Stub" serialization="custom">
      <org.joda.time.chrono.ISOChronology_-Stub>
      <org.joda.time.tz.CachedDateTimeZone
      resolves-to="org.joda.time.DateTimeZone$Stub" serialization="custom">
      <org.joda.time.DateTimeZone_-Stub>
      <string>Europe/Berlin</string>
      </org.joda.time.DateTimeZone_-Stub>
      </org.joda.time.tz.CachedDateTimeZone>
      </org.joda.time.chrono.ISOChronology_-Stub>
      </iChronology>
      </org.joda.time.LocalDate>
      2008-07-02 (2008-07-03)

      1. Main.java
        2 kB
        Jörg Schaible

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          John A McDonald
        • Votes:
          1 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: