-
Bug
-
Resolution: Fixed
-
P3
-
11, 11.0.9, 17, 20
-
b13
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8307011 | 20u-cpu | Sergey Bylokhov | P3 | Resolved | Fixed | master |
JDK-8304077 | 20.0.2 | Sergey Bylokhov | P3 | Resolved | Fixed | b03 |
JDK-8313282 | 17.0.10-oracle | Johny Jose | P3 | Resolved | Fixed | b02 |
JDK-8304081 | 17.0.8 | Sergey Bylokhov | P3 | Resolved | Fixed | b01 |
JDK-8304082 | 11.0.20 | Sergey Bylokhov | P3 | Resolved | Fixed | b01 |
ZoneId zid = ZoneId.of("UTC+01:30");
String s = zid.toString() + " 2023-01-01 00:00:00";
DateTimeFormatter FORMATTER;
DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
builder.appendZoneText(TextStyle.NARROW)
.appendLiteral(" ")
.append(DateTimeFormatter.ofPattern("uuuu-MM-dd"))
.appendLiteral(" ")
.append(DateTimeFormatter.ofPattern("HH:mm:ss"));
FORMATTER = builder.toFormatter();
ZonedDateTime.parse(s, FORMATTER);
The root cause is this line in that change:
https://github.com/openjdk/jdk/commit/5c3a01591c5c945926636fdc9f164d60b5b4f29e?diff=unified#diff-5fcf976db1c06e8f44a8671356d7e34fdfbf5b057baa852e7c3e015c8797c889R4263
Note that the comment said about French, but the "utc+" is ignored for all locales.
That fix had a CSR
https://mail.openjdk.org/pipermail/core-libs-dev/2020-February/064683.html
So the change was done intentionally, but it seems it contradicts the specification of the "appendZoneText" method, which is used in the test above. In the test the "+utc" is accepted as zoneID but rejected during parsing, but the spec says:
============
During parsing, either the textual zone name, the zone ID or the offset
* is accepted. Many textual zone names are not unique, such as CST can be
* for both "Central Standard Time" and "China Standard Time". In this
* situation, the zone id will be determined by the region information from
* formatter's
https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/time/format/DateTimeFormatterBuilder.html#appendZoneText(java.time.format.TextStyle)
So the implementation should be aligned with the spec or the specification should be updated.
- backported by
-
JDK-8304077 The "ZonedDateTime.parse" may not accept the "UTC+XX" zone id
- Resolved
-
JDK-8304081 The "ZonedDateTime.parse" may not accept the "UTC+XX" zone id
- Resolved
-
JDK-8304082 The "ZonedDateTime.parse" may not accept the "UTC+XX" zone id
- Resolved
-
JDK-8307011 The "ZonedDateTime.parse" may not accept the "UTC+XX" zone id
- Resolved
-
JDK-8313282 The "ZonedDateTime.parse" may not accept the "UTC+XX" zone id
- Resolved
- relates to
-
JDK-8236548 Localized time zone name inconsistency between English and other locales
- Resolved
-
JDK-8316096 java.time.format.DateTimeParseException when parsing UTC+00:00 with zxxx format
- Closed
- links to
-
Commit openjdk/jdk11u-dev/c6f00859
-
Commit openjdk/jdk17u-dev/b087032f
-
Commit openjdk/jdk20u/d44789c3
-
Commit openjdk/jdk/cfb0a25a
-
Review openjdk/jdk11u-dev/1793
-
Review openjdk/jdk17u-dev/1198
-
Review openjdk/jdk20u/14
-
Review openjdk/jdk/12868