-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
For renamed time zones org.joda.time.DateTimeZone.forID(String id) returns a time zone object that uses the new id even if you use the old id as the method parameter.
This brings me into trouble when I let two servers that have differen joda versions talk to each other. For instance a server with joda-time 2.3 sends time zone Asia/Rangoon to a server with joda time 2.10.5. The latter will change the time zone to Asia/Yangon when .DateTimeZone.forID is called in the deserialization. When the servers sends the time zone back to the former server, joda-time 2.3 does not know of the time zone Asia/Yangon that was introduced in 2017
By the way this change of names is not the case for java.util.TimeZone.getTimeZone(String ID) and java.time.ZoneId.of(String zoneId).
- Joda-Time version 2.10.5
Test testRangoonDateTimeZone fails for 2.10.5 but should pass
public void testRangoonDateTimeZone() throws Exception {
DateTimeZone zoneOld = DateTimeZone.forID("Asia/Rangoon");
assertEquals(zoneOld.getID(), "Asia/Rangoon");
DateTimeZone zoneNew = DateTimeZone.forID("Asia/Yangon");
assertEquals(zoneNew.getID(), "Asia/Yangon");
}
public void testRangoonJavaUtilTimeZone() throws Exception {
TimeZone zone = TimeZone.getTimeZone("Asia/Rangoon");
assertEquals(zone.getID(), "Asia/Rangoon");
TimeZone zoneNew = TimeZone.getTimeZone("Asia/Yangon");
assertEquals(zoneNew.getID(), "Asia/Yangon");
}
public void testRangoonJavaTimeZoneId() throws Exception {
ZoneId zone = ZoneId.of("Asia/Rangoon");
assertEquals(zone.getId(), "Asia/Rangoon");
ZoneId zoneNew = ZoneId.of("Asia/Yangon");
assertEquals(zoneNew.getId(), "Asia/Yangon");
}