-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8u192
-
x86_64
-
linux
A DESCRIPTION OF THE PROBLEM :
java.time.format.DateTimeFormatter.ISO_DATE_TIME can write to string formats with a java.time.ZoneId of "GMT0", but cannot parse them.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a string representation of a time in the "GMT0" zone from a ZonedDateTime using ZonedDateTime#format(DateTimeFormatter.ISO_DATE_TIME).
2. Attempt to parse the string back into a ZonedDateTime using ZonedDateTime#parse(DateTimeFormatter.ISO_DATE_TIME).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The formatter successfully parses the string it created. For example, "2019-05-20T11:28:38.154Z[GMT0]" is successfully parsed into a java.time.ZonedDateTime.
ACTUAL -
Exception in thread "main" java.time.format.DateTimeParseException: Text '2019-05-20T11:28:38.154Z[GMT0]' could not be parsed, unparsed text found at index 24
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1952)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
---------- BEGIN SOURCE ----------
import java.time.ZonedDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
class Gmt0FormatTest {
public static void main(String[] args) {
String time = ZonedDateTime.now().toInstant().atZone(ZoneId.of("GMT0")).format(DateTimeFormatter.ISO_DATE_TIME);
System.out.println(time); // e.g. "2019-05-20T11:28:38.154Z[GMT0]"
System.out.println(ZonedDateTime.parse(time, DateTimeFormatter.ISO_DATE_TIME)); // expect the same time string; actually throws java.time.format.DateTimeParseException
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Change your computer's timezone to "GMT" or "UTC" rather than "GMT0", I guess.
FREQUENCY : always
java.time.format.DateTimeFormatter.ISO_DATE_TIME can write to string formats with a java.time.ZoneId of "GMT0", but cannot parse them.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a string representation of a time in the "GMT0" zone from a ZonedDateTime using ZonedDateTime#format(DateTimeFormatter.ISO_DATE_TIME).
2. Attempt to parse the string back into a ZonedDateTime using ZonedDateTime#parse(DateTimeFormatter.ISO_DATE_TIME).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The formatter successfully parses the string it created. For example, "2019-05-20T11:28:38.154Z[GMT0]" is successfully parsed into a java.time.ZonedDateTime.
ACTUAL -
Exception in thread "main" java.time.format.DateTimeParseException: Text '2019-05-20T11:28:38.154Z[GMT0]' could not be parsed, unparsed text found at index 24
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1952)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
---------- BEGIN SOURCE ----------
import java.time.ZonedDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
class Gmt0FormatTest {
public static void main(String[] args) {
String time = ZonedDateTime.now().toInstant().atZone(ZoneId.of("GMT0")).format(DateTimeFormatter.ISO_DATE_TIME);
System.out.println(time); // e.g. "2019-05-20T11:28:38.154Z[GMT0]"
System.out.println(ZonedDateTime.parse(time, DateTimeFormatter.ISO_DATE_TIME)); // expect the same time string; actually throws java.time.format.DateTimeParseException
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Change your computer's timezone to "GMT" or "UTC" rather than "GMT0", I guess.
FREQUENCY : always
- duplicates
-
JDK-8138664 ZonedDateTime parse error for any date using 'GMT0' ZoneID
-
- Resolved
-