简体   繁体   中英

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM