Hello,

this topic was already discussed on this ML with LocalDate, but no  
solution was found,
so I ask again.

If I serialize a LocalTime with XStream to XML and back again the timezone
is changed from a FixedDateTimeZone to a CachedDateTimeZone what causes an  
1 hour-shift
in my case because my timezone is GMT+1.

Here the adapted test-code from the previous post that shows the problem:

import org.joda.time.LocalTime;
import com.thoughtworks.xstream.XStream;

LocalTime time1 = new LocalTime(8,0,0);
XStream xs = new XStream();
String xml1 = xs.toXML(time1);
LocalTime time2 = (LocalTime) xs.fromXML(xml1);
String xml2 = xs.toXML(time2);
LocalTime time3 = (LocalTime) xs.fromXML(xml2);

System.out.println("original time " + time1 );
System.out.println("original time to XML\n" + xml1 );
System.out.println("time from XML " + time2 );
System.out.println("deserialized time to XML\n" + xml2 );
System.out.println("time from XML " + time3 );

output:

original time 08:00:00.000
original time to XML
<org.joda.time.LocalTime>
   <iLocalMillis>28800000</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.LocalTime>
time from XML 09:00:00.000
deserialized time to XML
<org.joda.time.LocalTime>
   <iLocalMillis>28800000</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/Vienna</string>
         </org.joda.time.DateTimeZone_-Stub>
       </org.joda.time.tz.CachedDateTimeZone>
     </org.joda.time.chrono.ISOChronology_-Stub>
   </iChronology>
</org.joda.time.LocalTime>
time from XML 09:00:00.000

I use joda 1.6 and xstream 1.3.1.
Maybe this is a problem with XStream? Although I didn't had that problems  
with joda 1.2 and TimeOfDay.
Any hints are welcome.

thanks,
Lukas

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to