JodaOrg / joda-time

Joda-Time is the widely used replacement for the Java date and time classes prior to Java SE 8.
http://www.joda.org/joda-time/
Apache License 2.0
4.98k stars 986 forks source link

DateTimeZone#forID throws exception for ZoneOffset.UTC.getId() #717

Closed sdonfro closed 1 year ago

sdonfro commented 1 year ago

The Java Time API uses Zone ID "Z" for ZoneOffset.UTC. This ID value is not supported by Joda-Time so a simple conversion like the following throws an IllegalArgumentException stating that "The datetime zone id 'Z' is not recognised".

DateTimeZone.forID(ZoneOffset.UTC.getId())

Ideally DateTimeZone.UTC would be returned in this case.

I am using joda-time 2.12.5 with OpenJDK 17.0.5.

jodastephen commented 1 year ago

Seems reasonable, although there are quite a few cases where a simple conversion won't work.