[PATCH] Support for UTC Zones with TimeZone.getTimeZone()
naoto.sato at oracle.com
Thu Dec 21 17:10:37 UTC 2017
I can sponsor your fix. Here is the issue created for this:
If haven't already, would you take a look at the OpenJDK contribute
Also, I will need a regression test for the fix as well.
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,
> 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.
> On 12/16/17 2:27 AM, Mohamed Naufal wrote:
> 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
> TimeZone.getTimeZone() gets called, but it doesn't recognise UTC
> 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,
More information about the core-libs-dev