On Tue, 10 May 2022 17:43:24 GMT, Naoto Sato <na...@openjdk.org> wrote:

>> 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?
> Yes, it is intentional. The `Time-zone IDs` section in the `ZoneId` class 
> description is clear that zone id starting with "+/-" is a `ZoneOffset` 
> instance. Other ZoneIds should have offsets with prefix or region-based ids.

I was stumbling on this, too, but it is only ZoneOffset isntances that have 
those strange names without GMT/UTC prefix. Default ZoneId instances created 
from text strings always have a prefix. If you call ZoneId.of() with an offset 
only and no prefix it returns a ZoneOffset instance (see the test).


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

Reply via email to