behavior of ZonedDateTime when parsing string with conflicting zone id and offset

Viewed 936

I could not find what the expected behavior is when parsing a string with a conflicting zone id and offset.

For example:

ZonedDateTime d = ZonedDateTime.parse("2015-06-17T12:55:33+05:00[Europe/Amsterdam]");
println(d.toString()); // prints 2015-06-17T12:55:33+02:00[Europe/Amsterdam]

In this case parse() seems to ignore the incorrect offset of +05:00 and uses the offset determined by the zone ID (Europe/Amsterdam)

As the documentation says:

The offset cannot be freely set, as the zone controls which offsets are valid.

I would have expected parse() throwing an exception because +05:00 is an invalid offset for zone Europe/Amsterdam. What is the correct behavior in this case?

1 Answers
Related