A DESCRIPTION OF THE PROBLEM :
public static Instant parse(CharSequence text)" method from java.time.Instant does fails to parse all ISO 8601 format.
For example, Instant .parse("2017-01-01T00:00:00.000+0200"); and Instant .parse("2017-01-01T00:00:00.000+02");fails but Instant .parse("2017-01-01T00:00:00.000+02:00"); works when both formats should be accepted according to ISO-8601 requirements.
C.f. https://en.wikipedia.org/wiki/ISO_8601 : "An offset of zero, in addition to having the special representation "Z", can also be stated numerically as "+02:00", "+0200", or "+02""
The bug is the same as https://bugs.openjdk.org/browse/JDK-8176547 and was introduced by https://bugs.openjdk.org/browse/JDK-8166138
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Instant .parse("2017-01-01T00:00:00.000+02");
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Method should return a valid instance of class Instant.
ACTUAL -
Method throws java.time.format.DateTimeParseException
Exception in thread "main" java.time.format.DateTimeParseException: Text '2017-01-01T00:00:00.000+02' could not be parsed at index 23
at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2052)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1954)
at java.base/java.time.Instant.parse(Instant.java:397)
at TimeTest.main(TimeTest.java:6)
---------- BEGIN SOURCE ----------
public class TimeTest {
public static void main(String[] args) {
Instant.parse("2017-01-01T00:00:00.000+02");
}
}
---------- END SOURCE ----------
public static Instant parse(CharSequence text)" method from java.time.Instant does fails to parse all ISO 8601 format.
For example, Instant .parse("2017-01-01T00:00:00.000+0200"); and Instant .parse("2017-01-01T00:00:00.000+02");fails but Instant .parse("2017-01-01T00:00:00.000+02:00"); works when both formats should be accepted according to ISO-8601 requirements.
C.f. https://en.wikipedia.org/wiki/ISO_8601 : "An offset of zero, in addition to having the special representation "Z", can also be stated numerically as "+02:00", "+0200", or "+02""
The bug is the same as https://bugs.openjdk.org/browse/JDK-8176547 and was introduced by https://bugs.openjdk.org/browse/JDK-8166138
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Instant .parse("2017-01-01T00:00:00.000+02");
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Method should return a valid instance of class Instant.
ACTUAL -
Method throws java.time.format.DateTimeParseException
Exception in thread "main" java.time.format.DateTimeParseException: Text '2017-01-01T00:00:00.000+02' could not be parsed at index 23
at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2052)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1954)
at java.base/java.time.Instant.parse(Instant.java:397)
at TimeTest.main(TimeTest.java:6)
---------- BEGIN SOURCE ----------
public class TimeTest {
public static void main(String[] args) {
Instant.parse("2017-01-01T00:00:00.000+02");
}
}
---------- END SOURCE ----------
- csr for
-
JDK-8365182 Class java.time.Instant cannot parse all ISO 8601 date formats
-
- Draft
-
- links to
-
Review(master) openjdk/jdk/26708