Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.4.3
-
Fix Version/s: 1.4.4
-
Component/s: Converters
-
Labels:None
-
JDK version and platform:1.6.0_23 for linux
Description
Test case:
java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("GMT+0:00"));
final XStream instance = new XStream();
final java.sql.Timestamp expected = new java.sql.Timestamp(0);
final String marshalled = instance.toXML(expected);
java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("GMT-8:00"));
final java.sql.Timestamp got = (java.sql.Timestamp) instance.fromXML(marshalled);
Assert.assertEquals(expected, got);
Test result:
shouldHandleTimezoneForSqlTimestamp(com.thoughtworks.xstream.XStreamTest) Time elapsed: 0.148 sec <<< FAILURE!
java.lang.AssertionError: expected:<1969-12-31 16:00:00.0> but was:<1970-01-01 00:00:00.0>
Proposal patch in attachment.
The presentation of the value is on purpose, however, XStream should always use UTC to guarantee the same timestamp independent of the current time zone. Fixed in trunk.