On Mon, 9 May 2022 18:59:43 GMT, Naoto Sato <na...@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.

Marked as reviewed by uschindler (Author).

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

> 537:     public static TimeZone getTimeZone(ZoneId zoneId) {
> 538:         String tzid = zoneId.getId(); // throws an NPE if null
> 539:         if (zoneId instanceof ZoneOffset zo) {

I like this because it is much faster than the conversion to ZoneId and parsing 
it back! It is similar to use of SimpleTimeZone, but this is better as the 
returned timezone is unmodifiable, correct?

test/jdk/java/util/TimeZone/ZoneOffsetRoundTripTest.java line 43:

> 41:     private Object[][] testZoneOffsets() {
> 42:         return new Object[][] {
> 43:                 {ZoneId.of("Z"), 0},

I know, `ZoneId.of()` should parse this as a `ZoneOffset` and return a 
`ZoneOffset` instance, but maybe add also the other string variants with prefix 
(`ZoneId.of("UTC+00:00:01")` or `ZoneId.of("GMT+00:00:01")` as data items. 
Maybe also use `ZoneOffset.of()` for the plain zones to be explicit.


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

Reply via email to