-
Bug
-
Resolution: Fixed
-
P4
-
18
On MacOS testcase TestZoneTextPrinterParser.test_roundTripAtOverlap fails
with :
22:28:09 test test.java.time.format.TestZoneTextPrinterParser.test_roundTripAtOverlap("yyyy-MM-dd HH:mm:ss.SSS z", "2021-11-07 01:30:00.000 EST"): failure
22:28:09 java.time.format.DateTimeParseException: Text '2021-11-07 01:30:00.000 EST' could not be parsed at index 24
22:28:09 at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2056)
22:28:09 at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1958)
22:28:09 at java.base/java.time.ZonedDateTime.parse(ZonedDateTime.java:600)
22:28:09 at test.java.time.format.TestZoneTextPrinterParser.test_roundTripAtOverlap(TestZoneTextPrinterParser.java:266)
The line: https://github.com/openjdk/jdk18u/blob/1ab6f9395f784293deb37ea0186db59d1166ae40/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java#L266
throws DateTimeParseException if the current locale cannot parse the zone,
similar to a previous issue in a different testcase: https://bugs.openjdk.java.net/browse/JDK-8282023
To recreate:
String pattern = "yyyy-MM-dd HH:mm:ss.SSS z";
String input = "2021-11-07 01:30:00.000 EST";
var dtf = DateTimeFormatter.ofPattern(pattern);
String parsed = dtf.format(ZonedDateTime.parse(input, dtf));
Using the following resolves the problem:
var dtf = DateTimeFormatter.ofPattern(pattern, Locale.ROOT);
with :
22:28:09 test test.java.time.format.TestZoneTextPrinterParser.test_roundTripAtOverlap("yyyy-MM-dd HH:mm:ss.SSS z", "2021-11-07 01:30:00.000 EST"): failure
22:28:09 java.time.format.DateTimeParseException: Text '2021-11-07 01:30:00.000 EST' could not be parsed at index 24
22:28:09 at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2056)
22:28:09 at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1958)
22:28:09 at java.base/java.time.ZonedDateTime.parse(ZonedDateTime.java:600)
22:28:09 at test.java.time.format.TestZoneTextPrinterParser.test_roundTripAtOverlap(TestZoneTextPrinterParser.java:266)
The line: https://github.com/openjdk/jdk18u/blob/1ab6f9395f784293deb37ea0186db59d1166ae40/test/jdk/java/time/test/java/time/format/TestZoneTextPrinterParser.java#L266
throws DateTimeParseException if the current locale cannot parse the zone,
similar to a previous issue in a different testcase: https://bugs.openjdk.java.net/browse/JDK-8282023
To recreate:
String pattern = "yyyy-MM-dd HH:mm:ss.SSS z";
String input = "2021-11-07 01:30:00.000 EST";
var dtf = DateTimeFormatter.ofPattern(pattern);
String parsed = dtf.format(ZonedDateTime.parse(input, dtf));
Using the following resolves the problem:
var dtf = DateTimeFormatter.ofPattern(pattern, Locale.ROOT);