How's GregorianChronology[Europe/Berlin] different from GregorianChronology[+02:00]?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How's GregorianChronology[Europe/Berlin] different from GregorianChronology[+02:00]?

Marcel Stör
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);

Cheers,
Marcel

--
Marcel Stör, http://www.frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

------------------------------------------------------------------------------
WINDOWS 8 is here.
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How's GregorianChronology[Europe/Berlin] different from GregorianChronology[+02:00]?

jodastephen
On 28 October 2012 20:58, Marcel Stör <[hidden email]> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...