<i18n dev> [PATCH] Support for UTC Zones with TimeZone.getTimeZone()

Naoto Sato naoto.sato at oracle.com
Thu Dec 21 17:10:37 UTC 2017


Hi Naufal,

I can sponsor your fix. Here is the issue created for this:

https://bugs.openjdk.java.net/browse/JDK-8193938

If haven't already, would you take a look at the OpenJDK contribute 
page? [1]

Also, I will need a regression test for the fix as well.

Thanks!
Naoto

[1] http://openjdk.java.net/contribute/

On 12/20/17 5:44 PM, Mohamed Naufal wrote:
> Hi Naoto,
> 
> Thank you for the feedback, I'll send an updated patch shortly.
> 
> Best regards,
> Naufal
> 
> On 21 December 2017 at 05:19, Naoto Sato <naoto.sato at oracle.com 
> <mailto:naoto.sato at oracle.com>> wrote:
> 
>     Hi Naufal,
> 
>     Thank you for the patch. It does seem to be a bug. However, TimeZone
>     class defines CustomID as "GMT+(offset)", so I'd rather fix it in
>     GregorianCalendar.from() to recognize those "UTC+offset" zones.
> 
>     Naoto
> 
> 
>     On 12/16/17 2:27 AM, Mohamed Naufal wrote:
> 
>         Hi,
> 
>         I noticed that with the following data:
> 
>         LocalDateTime ldt = LocalDateTime.parse("2017-01-01T00:00:00");
>         ZonedDateTime dt1 = ZonedDateTime.of(ldt, ZoneId.of("GMT+10"));
>         ZonedDateTime dt2 = ZonedDateTime.of(ldt, ZoneId.of("UTC+10"));
> 
>         dt1.equals(dt2) returns true as expected, but with:
> 
>         GregorianCalendar gc1 = GregorianCalendar.from(dt1);
>         GregorianCalendar gc2 = GregorianCalendar.from(dt2);
> 
>         gc1.equals(gc2) returns false.
> 
>         Looking at the code, I see when a GregorianCalendar is being
>         constructed,
>         TimeZone.getTimeZone() gets called, but it doesn't recognise UTC
>         time-zones
>         with offsets, and falls back to GMT(+0), whereas ZoneId treats
>         GMT and UTC
>         based zones equivalently.
> 
>         PFA a patch to fix this.
> 
>         Thank you,
>         Naufal
> 
> 


More information about the i18n-dev mailing list