-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b112
-
os_x
FULL PRODUCT VERSION :
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b123)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b65, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin Brainys-Mac-mini.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
For date-time string formats both ISO 8601 and RFC 3339 allow either a long time zone offset including a colon and minutes like this: +01:00
_and_ they allow a shorter offset without the colon and minutes like this: +01
The "ZonedDateTime" class included in Java 8's new java.time.* classes is documented as parsing ISO 8601-like strings. While true of the longer time zone offsets, the shorter offsets cause the class to throw a DateTimeParseException, like this:
java.time.format.DateTimeParseException: Text '2013-12-11T21:25:04.800842+01' could not be parsed at index 26
Here is some demonstration source code???
String x = "2013-12-11T21:25:04.800842+01:00";
String y = "2013-12-11T21:25:04.800842+01";
ZonedDateTime zonedDateTime_x = ZonedDateTime.parse( x ); // Succeeds.
ZonedDateTime zonedDateTime_y = ZonedDateTime.parse( y ); // Fails.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply run these 4 lines of code.
String x = "2013-12-11T21:25:04.800842+01:00";
String y = "2013-12-11T21:25:04.800842+01";
ZonedDateTime zonedDateTime_x = ZonedDateTime.parse( x ); // Succeeds.
ZonedDateTime zonedDateTime_y = ZonedDateTime.parse( y ); // Fails.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both calls to "parse" should succeed.
ACTUAL -
The second call to "parse" throws an exception like this one:
java.time.format.DateTimeParseException: Text '2013-12-11T21:25:04.800842+01' could not be parsed at index 26
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.time.format.DateTimeParseException: Text '2013-12-11T21:25:04.800842+01' could not be parsed at index 26
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
String x = "2013-12-11T21:25:04.800842+01:00";
String y = "2013-12-11T21:25:04.800842+01";
ZonedDateTime zonedDateTime_x = ZonedDateTime.parse( x ); // Succeeds.
ZonedDateTime zonedDateTime_y = ZonedDateTime.parse( y ); // Fails.
---------- END SOURCE ----------
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b123)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b65, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin Brainys-Mac-mini.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
For date-time string formats both ISO 8601 and RFC 3339 allow either a long time zone offset including a colon and minutes like this: +01:00
_and_ they allow a shorter offset without the colon and minutes like this: +01
The "ZonedDateTime" class included in Java 8's new java.time.* classes is documented as parsing ISO 8601-like strings. While true of the longer time zone offsets, the shorter offsets cause the class to throw a DateTimeParseException, like this:
java.time.format.DateTimeParseException: Text '2013-12-11T21:25:04.800842+01' could not be parsed at index 26
Here is some demonstration source code???
String x = "2013-12-11T21:25:04.800842+01:00";
String y = "2013-12-11T21:25:04.800842+01";
ZonedDateTime zonedDateTime_x = ZonedDateTime.parse( x ); // Succeeds.
ZonedDateTime zonedDateTime_y = ZonedDateTime.parse( y ); // Fails.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply run these 4 lines of code.
String x = "2013-12-11T21:25:04.800842+01:00";
String y = "2013-12-11T21:25:04.800842+01";
ZonedDateTime zonedDateTime_x = ZonedDateTime.parse( x ); // Succeeds.
ZonedDateTime zonedDateTime_y = ZonedDateTime.parse( y ); // Fails.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both calls to "parse" should succeed.
ACTUAL -
The second call to "parse" throws an exception like this one:
java.time.format.DateTimeParseException: Text '2013-12-11T21:25:04.800842+01' could not be parsed at index 26
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.time.format.DateTimeParseException: Text '2013-12-11T21:25:04.800842+01' could not be parsed at index 26
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
String x = "2013-12-11T21:25:04.800842+01:00";
String y = "2013-12-11T21:25:04.800842+01";
ZonedDateTime zonedDateTime_x = ZonedDateTime.parse( x ); // Succeeds.
ZonedDateTime zonedDateTime_y = ZonedDateTime.parse( y ); // Fails.
---------- END SOURCE ----------
- relates to
-
JDK-8210336 DateTimeFormatter predefined formatters should support short time zone offsets
-
- Open
-