Jon Freedman
Jon Freedman

Reputation: 9687

Joda-Time DateTimeZone

I have a unit test which attempts to verify some behavior between Israel/London, one of the first things I check is the timezone offset in Asia/Jerusalem as follows

val clientTimezone = DateTimeZone.forID("Asia/Jerusalem")
val now = new DateTime(DateTimeZone.forID("Etc/GMT"))
val clientOffset = clientTimezone.getOffset(now) / (1000 * 60)

Right now it's 5pm in London, 7pm in Israel, and 4pm GMT, but when I run this code I get now initialized to 16:00, and clientOffset = 120 not 180. If I swap Asia/Jerusalem for Europe/London I get a clientOffset = 60.

Am I using Joda correctly, or does it have the wrong time? These tests were fine before this weekend. This is with version joda-time 2.1

Upvotes: 0

Views: 2850

Answers (1)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241420

The time zone rules for Israel have changed. You'll need to use the 2013d version of the IANA time zone database. This is included in JodaTime 2.3.

If you can't update JodaTime, you can update the TZDB data separately following these instructions.

Upvotes: 2

Related Questions