-
Bug
-
Resolution: Fixed
-
P3
-
9
-
b09
-
generic
-
generic
FULL PRODUCT VERSION :
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ***** 4.10.0-35-generic #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
locale=en_US
A DESCRIPTION OF THE PROBLEM :
When parsing a date time string that contains a time zone like AKST, AKDT, HST or AST with a DateTimeFormatter built from a pattern containing 'z', java 9 returns the SystemV variant of those timezone, which then behave differently as the "modern" ones. Looks like it's also an issue with long time zone ("Alaska Standard Time")
From my digging I noticed that the PrefixTree generated by ZoneTextPrinterParser.getTree is different in java 8 and java 9, and this may be caused by a different order in the content returned by TimeZoneNameUtility.getZoneStrings(Locale.getDefault())
Is this an expected behavior of java 9? (other american time zones are parsed to the modern version: PST -> America/Los_Angeles)
REGRESSION. Last worked in version 8u131
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
{},ISO,America/Juneau
{},ISO,America/Juneau
{},ISO,Pacific/Honolulu
{},ISO,SystemV/AST4ADT
{InstantSeconds=1505313033},ISO,America/Juneau resolved to 2017-09-13T06:30:33.123
2017-09-13T14:30Z
{InstantSeconds=1505313033},ISO,America/Anchorage resolved to 2017-09-13T06:30:33.123
2017-09-13T14:30Z
ACTUAL -
{},ISO,SystemV/YST9
{},ISO,SystemV/YST9
{},ISO,SystemV/HST10
{},ISO,SystemV/AST4ADT
{InstantSeconds=1505316633},ISO,SystemV/YST9 resolved to 2017-09-13T06:30:33.123
2017-09-13T15:30Z
{InstantSeconds=1505313033},ISO,America/Anchorage resolved to 2017-09-13T06:30:33.123
2017-09-13T14:30Z
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
public class Main{
public static void main(String[] args){
DateTimeFormatter timezoneFormatter = DateTimeFormatter.ofPattern("z");
TemporalAccessor temporalAccessor = timezoneFormatter.parse("AKST");
System.out.println(temporalAccessor);
temporalAccessor = timezoneFormatter.parse("AKDT");
System.out.println(temporalAccessor);
temporalAccessor = timezoneFormatter.parse("HST");
System.out.println(temporalAccessor);
temporalAccessor = timezoneFormatter.parse("AST");
System.out.println(temporalAccessor);
DateTimeFormatter isoFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mmX").withZone(ZoneOffset.UTC);
temporalAccessor = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSz").parse("2017-09-13T06:30:33.123AKST");
System.out.println(temporalAccessor);
System.out.println(isoFormatter.format(temporalAccessor));
temporalAccessor = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSVV").parse("2017-09-13T06:30:33.123America/Anchorage");
System.out.println(temporalAccessor);
System.out.println(isoFormatter.format(temporalAccessor));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
use java.locale.providers=COMPAT
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ***** 4.10.0-35-generic #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
locale=en_US
A DESCRIPTION OF THE PROBLEM :
When parsing a date time string that contains a time zone like AKST, AKDT, HST or AST with a DateTimeFormatter built from a pattern containing 'z', java 9 returns the SystemV variant of those timezone, which then behave differently as the "modern" ones. Looks like it's also an issue with long time zone ("Alaska Standard Time")
From my digging I noticed that the PrefixTree generated by ZoneTextPrinterParser.getTree is different in java 8 and java 9, and this may be caused by a different order in the content returned by TimeZoneNameUtility.getZoneStrings(Locale.getDefault())
Is this an expected behavior of java 9? (other american time zones are parsed to the modern version: PST -> America/Los_Angeles)
REGRESSION. Last worked in version 8u131
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
{},ISO,America/Juneau
{},ISO,America/Juneau
{},ISO,Pacific/Honolulu
{},ISO,SystemV/AST4ADT
{InstantSeconds=1505313033},ISO,America/Juneau resolved to 2017-09-13T06:30:33.123
2017-09-13T14:30Z
{InstantSeconds=1505313033},ISO,America/Anchorage resolved to 2017-09-13T06:30:33.123
2017-09-13T14:30Z
ACTUAL -
{},ISO,SystemV/YST9
{},ISO,SystemV/YST9
{},ISO,SystemV/HST10
{},ISO,SystemV/AST4ADT
{InstantSeconds=1505316633},ISO,SystemV/YST9 resolved to 2017-09-13T06:30:33.123
2017-09-13T15:30Z
{InstantSeconds=1505313033},ISO,America/Anchorage resolved to 2017-09-13T06:30:33.123
2017-09-13T14:30Z
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
public class Main{
public static void main(String[] args){
DateTimeFormatter timezoneFormatter = DateTimeFormatter.ofPattern("z");
TemporalAccessor temporalAccessor = timezoneFormatter.parse("AKST");
System.out.println(temporalAccessor);
temporalAccessor = timezoneFormatter.parse("AKDT");
System.out.println(temporalAccessor);
temporalAccessor = timezoneFormatter.parse("HST");
System.out.println(temporalAccessor);
temporalAccessor = timezoneFormatter.parse("AST");
System.out.println(temporalAccessor);
DateTimeFormatter isoFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mmX").withZone(ZoneOffset.UTC);
temporalAccessor = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSz").parse("2017-09-13T06:30:33.123AKST");
System.out.println(temporalAccessor);
System.out.println(isoFormatter.format(temporalAccessor));
temporalAccessor = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSVV").parse("2017-09-13T06:30:33.123America/Anchorage");
System.out.println(temporalAccessor);
System.out.println(isoFormatter.format(temporalAccessor));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
use java.locale.providers=COMPAT
- relates to
-
JDK-8201507 Generate alias entries in j.t.f.ZoneName from tzdb at build time
-
- Resolved
-