Unexpected +1hr diff with unmarshalled dateTime in Daylight Savings...
Subject: Unexpected +1hr difference with JAXB-unmarshalled dateTime value that falls within the Daylight Savings part of the year.
When unmarshalling an XML file with a dateTime element that has a value falling within the Daylight Savings period of the year, I find that the JAXB-generated class returns a Calendar object that has a time that is +1 hour later than expected.
I've compared this with a simple interrogation of the SysClock in Java - e.g. System.currentTimeInMillis() and with code written in C ( - time() function).
Both of these routes to the SysClock give the expected correct result, and both seem to confirm a +1hr increase in the JAXB-generated class' Calendar object.
The JAXB-generated class returns a Calendar object that has its zone field set to
A call to java.util.TimeZone.getDefault() before and after unmarshalling shows the JVM has a valid TimeZone object (="Europe/London") with sensible fields.
The work-around seems to be to call theCalendarObject.setTimeZone(java.util.TimeZone.getDefault())
before calling any other method on the Calendar object, whereafter theCalendarObject gives the correct time
results. Any calls like theCalendarObject.getTimeInMillis() before the setTimeZone(...) seem to fix the +1hr
and makes the work-around ineffective.
By default, the SystemProperty java.timezone="". Setting SystemProperty java.timezone="Europe/London" changes
nothing and the calls to TimeZone.getDefault() before and after unmarshalling still return valid results.
However setting java.timezone=GMT leaves the JAXB unmarshalled values still at +1hr, but prevents the fix from working and it also alters the results of a call to theCalendarObject.set(year,month,day,hour,min,sec) [to set the same date that falls within Daylight Savings period of the year] to also be +1hour later than expected.
If anyone fancies taking a look, I've got a simple Junit test case and test-run output.
Using: jwsdp-1.6, J2SE (jdk5.0.4), Windows 2000/SP4.
My timezone is "Europe/London" so my summer Daylight Savings Time is known as BST (meaning British Summer