Please let me know if what I found is a bug or not. I'm using version 1.5.2.
When the hour of day is set to the ambiguous hour on the daylight to
standard time transition in a given time zone what should the result be? The
daylight hour or the standard hour for all time zones? I can't find anything
that documents this behavior.
My test code below returns different results for different time zones.
/**
* Verify Joda converts the hour of day the same for regions north and
south of the equator on the DST
* daylight to standard time transition.
*/
@Test
public void jodaTest ()
{
Chronology chronUTC =
GregorianChronology.getInstance(DateTimeZone.UTC);
DateTime usCentralStandardInUTC = new DateTime(2008, 11, 2, 7, 0, 0,
0, chronUTC);
DateTime usCentralDaylightInUTC = new DateTime(2008, 11, 2, 6, 0, 0,
0, chronUTC);
Chronology chronUSCentral =
GregorianChronology.getInstance(DateTimeZone.forID("US/Central"));
Assert.assertTrue("Should be standard time",
chronUSCentral.getZone().isStandardOffset(
usCentralStandardInUTC.getMillis()));
Assert.assertFalse("Should be daylight time",
chronUSCentral.getZone().isStandardOffset(
usCentralDaylightInUTC.getMillis()));
DateTime usCentralStandardInUSCentral =
usCentralStandardInUTC.toDateTime(chronUSCentral);
DateTime usCentralDaylightInUSCentral =
usCentralDaylightInUTC.toDateTime(chronUSCentral);
assertEquals(1, usCentralStandardInUSCentral.getHourOfDay());
assertEquals(usCentralStandardInUSCentral.getHourOfDay(),
usCentralDaylightInUSCentral.getHourOfDay());
Assert.assertTrue(usCentralStandardInUSCentral.getMillis() !=
usCentralDaylightInUSCentral.getMillis());
DateTime australiaNSWStandardInUTC = new DateTime(2008, 4, 5, 16, 0,
0, 0, chronUTC);
DateTime australiaNSWDaylightInUTC = new DateTime(2008, 4, 5, 15, 0,
0, 0, chronUTC);
Chronology chronAusNSW =
GregorianChronology.getInstance(DateTimeZone.forID("Australia/NSW"));
Assert.assertTrue("Should be standard time",
chronAusNSW.getZone().isStandardOffset(
australiaNSWStandardInUTC.getMillis()));
Assert.assertFalse("Should be daylight time",
chronAusNSW.getZone().isStandardOffset(
australiaNSWDaylightInUTC.getMillis()));
DateTime australiaNSWStandardInAustraliaNSW =
australiaNSWStandardInUTC.toDateTime(chronAusNSW);
DateTime australiaNSWDaylightInAusraliaNSW =
australiaNSWDaylightInUTC.toDateTime(chronAusNSW);
assertEquals(2, australiaNSWStandardInAustraliaNSW.getHourOfDay());
assertEquals(australiaNSWStandardInAustraliaNSW.getHourOfDay(),
australiaNSWDaylightInAusraliaNSW.getHourOfDay());
Assert.assertTrue(australiaNSWStandardInAustraliaNSW.getMillis() !=
australiaNSWDaylightInAusraliaNSW.getMillis());
// Verify that setting the hour of day on the DST boundary results
in a daylight time for
// both time zones.
assertEquals(usCentralDaylightInUSCentral,
usCentralStandardInUSCentral.withHourOfDay(1));
assertEquals(australiaNSWDaylightInAusraliaNSW,
australiaNSWStandardInAustraliaNSW.withHourOfDay(2));
}
The very last assertion fails on the Australia time zone cutover.
java.lang.AssertionError: expected:<2008-04-06T02:00:00.000+11:00> but
was:<2008-04-06T02:00:00.000+10:00>
Bryan Madsen
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest