<i18n dev> RFR: 8285844: TimeZone.getTimeZone(ZoneOffset) does not work for all ZoneOffsets and returns GMT unexpected

Jaikiran Pai jpai at openjdk.java.net
Tue May 10 14:24:00 UTC 2022


On Mon, 9 May 2022 18:59:43 GMT, Naoto Sato <naoto at openjdk.org> wrote:

> This is to extend the `Custom ID`s in `java.util.TimeZone` class to support second-level resolution, enabling round trips with `java.time.ZoneOffset`s. Corresponding CSR is also being drafted.

src/java.base/share/classes/java/util/TimeZone.java line 543:

> 541:             return new ZoneInfo(totalSecs == 0 ? "UTC" : GMT_ID + tzid, totalSecs);
> 542:         } else {
> 543:             return getTimeZone(tzid, true);

Before the change in this PR, we used to prefix `GMT` to (non-custom timezone ids) if the timezone id returned by `ZoneId#getId()` started with the `+` or `-` sign, before calling `getTimeZone(modifiedTzid, true)`. 
With this change, for `ZoneId`s that aren't `ZoneOffset` instance, we now call `getTimeZone(originalTzid, true)`, without first checking/prefixing the id with `GMT`. Is that an intentional change and would that potentially cause `getTimeZone(String, boolean)` to return a different result?

-------------

PR: https://git.openjdk.java.net/jdk/pull/8606


More information about the i18n-dev mailing list