Skip to main content

Unexpected +1hr diff with unmarshalled dateTime in Daylight Savings...

3 replies [Last post]
Joined: 2005-11-30

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.

Many thanks,

Steve B

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

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-09

It would be great if you can file a bug on about this.

And can you show us the text that you unmarshalled?

Joined: 2005-11-30

Will do, once I've worked out how to post a bug report.
It's 8pm here so it won't get done until tomorrow.



Joined: 2005-11-30

Posted at as Issue #107