On 28 October 2012 20:58, Marcel Stör <mar...@frightanic.com> wrote:
> Today after DST shift one of our unit tests failed. The method under
> test no longer returned proper values.
>
> The method takes a javax.xml.datatype.XMLGregorianCalendar, converts it
> to DateTime, and sets the time to last milli of the day i.e.
> 23:59:59.999. When I checked the final value it was
> 2012-10-28T23:59:59.999+02:00 which is correct apart from the +2
> (instead of +1) time zone.
>
> When I checked the chronology of the DateTime object it said
> "GregorianChronology[+02:00]". If I manually set the chronology by
> invoking .withChronology(GregorianChronology.getInstance()) I get
> "GregorianChronology[Europe/Berlin]" and the code works as intended.
>
> This is the code:
> new DateTime(xmlCal.toGregorianCalendar()).plusDays(1).minusMillis(1);

I don't think this is anything to do with XMLGregorianCalendar
(because you convert to GregorianCalendar first), although I could be
wrong.

The conversion from Calendar to DateTime occurs in the Joda-Time class
CalendarConverter. That class uses the time-zone of the Calendar
object to set the time-zone in the DateTime object. If the time-zone
conversion fails, the default time-zone of the JVM is used.

Somewhere is that conversion, the time-zone isn't doing what it did
before. I'd recommend you debug against a source download (as I don't
have enough information to tell you where the problem is).

Stephen

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to