hi all,

i think there is a bug in DateTimeZone.toTimeZone(): it does not
return the correct java.util.TimeZone when the DateTimeZone was
created from an offset (rather than an ID). (As a direct consequence
of this, the java.util.GregorianCalendar returned by
AbstractDateTime.toGregorianCalendar() is also incorrect, because it
is based on the wrong java.util.TimeZone.)

please have a look at the following test case. in my opinion, all
assertions should succeed, but the last one fails because the offset
of the java.util.TimeZone returned by DateTimeZone.toTimeZone() is in
fact 0.

------------------------------------------------
// a dateTime in winter
final long t = new DateTime("2006-01-12T12:12:00").getMillis();

DateTimeZone dtz;

dtz = DateTimeZone.forID("UTC");
assertEquals(dtz.getOffset(t), 0); // OK
assertEquals(dtz.toTimeZone().getOffset(t), 0); // OK

dtz = DateTimeZone.forID("America/Los_Angeles");
assertEquals(dtz.getOffset(t), -8 * 60 * 60 * 1000); // OK
assertEquals(dtz.toTimeZone().getOffset(t), -8 * 60 * 60 * 1000); // OK

dtz = DateTimeZone.forOffsetHours(-8);
assertEquals(dtz.getOffset(t), -8 * 60 * 60 * 1000); // OK
assertEquals(dtz.toTimeZone().getOffset(t), -8 * 60 * 60 * 1000); // FAILS
------------------------------------------------

Is this a misunderstanding on my part or a genuine bug?

(this is for joda-time 1.4)

  cheers,
  gerald

-- 
http://www.gerald-loeffler.net

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to