I see a difference I don't understand between ZonedDateTime.parse(...) and ZonedDateTime.of(...). Here is the example:
private static final DateTimeFormatter DATE_TIME_FORMAT = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("dd-MMM-yyyy HH:mm:ss z")
.toFormatter();
@Test
public void dates() {
assertEquals(
ZonedDateTime.of(2001, 10, 1, 17, 7, 15, 0, ZoneId.of("EST", ZoneId.SHORT_IDS)),
ZonedDateTime.parse("01-OCT-2001 17:07:15 EST", DATE_TIME_FORMAT));
}
The result to my surprise is not passing test but rather:
java.lang.AssertionError:
Expected :2001-10-01T17:07:15-05:00
Actual :2001-10-01T17:07:15-04:00[America/New_York]
Any tips on what is going on please?
Edit: It seems that the problem is that in parse(...) method the EST gets resolves as ZoneRegion where the ZoneId.SHORT_IDS maps EST to ZoneOffset. I would be interested if there is a reason behind this inconsistency.