Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8047231 | 9 | Stephen Colebourne | P3 | Resolved | Fixed | b20 |
JDK-8048442 | 8u25 | Stephen Colebourne | P3 | Resolved | Fixed | b05 |
JDK-8053698 | emb-8u26 | Stephen Colebourne | P3 | Resolved | Fixed | b17 |
The fix for JDK-8033662 enabled a ZonedDateTime to be parsed when withZone() is used. Unfortunately, the fix did not allow an Instant to be parsed. More generally, there is no current way to parse an instant except using the appendInstant() method of the formatter builder.
@Test
public void test_parse_Instant_withZone1() {
DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss ").appendZoneId().toFormatter();
TemporalAccessor acc = fmt.parse("2014-06-30 01:02:03 Europe/Paris");
Instant actual = Instant.from(acc);
assertEquals(actual, ZonedDateTime.of(2014, 6, 30, 1, 2, 3, 0, PARIS).toInstant());
}
@Test
public void test_parse_Instant_withZone2() {
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(PARIS);
TemporalAccessor acc = fmt.parse("2014-06-30 01:02:03");
Instant actual = Instant.from(acc);
assertEquals(actual, ZonedDateTime.of(2014, 6, 30, 1, 2, 3, 0, PARIS).toInstant());
}
Tests fail in the from() method because it does not make available INSTANT_SECONDS even though sufficient data is available.
@Test
public void test_parse_Instant_withZone1() {
DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss ").appendZoneId().toFormatter();
TemporalAccessor acc = fmt.parse("2014-06-30 01:02:03 Europe/Paris");
Instant actual = Instant.from(acc);
assertEquals(actual, ZonedDateTime.of(2014, 6, 30, 1, 2, 3, 0, PARIS).toInstant());
}
@Test
public void test_parse_Instant_withZone2() {
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(PARIS);
TemporalAccessor acc = fmt.parse("2014-06-30 01:02:03");
Instant actual = Instant.from(acc);
assertEquals(actual, ZonedDateTime.of(2014, 6, 30, 1, 2, 3, 0, PARIS).toInstant());
}
Tests fail in the from() method because it does not make available INSTANT_SECONDS even though sufficient data is available.
- backported by
-
JDK-8047231 Unable to parse an Instant from fields
- Resolved
-
JDK-8048442 Unable to parse an Instant from fields
- Resolved
-
JDK-8053698 Unable to parse an Instant from fields
- Resolved