jsonb-api icon indicating copy to clipboard operation
jsonb-api copied to clipboard

ZoneId serialization

Open martijndwars opened this issue 5 years ago • 1 comments

According to the JSON-B specification a java.time.ZoneId instance needs to be serialized as follows (emphasis mine):

Implementations MUST support the deserialization of any time zone ID format specified in java.time.ZoneId into a field or property of type java.time.ZoneId. The serialization format of java.time.ZoneId is the normalized zone ID as specified in java.time.ZoneId.

The normalized part makes a difference when you have a ZoneId.of("UTC"), for example. The zone ID is "UTC", but the normalized zone ID is "Z", as shown by this jshell session:

jshell> import java.time.*;

jshell> ZoneId.of("UTC").getId()
$2 ==> "UTC"

jshell> ZoneId.of("UTC").normalized().getId()
$3 ==> "Z"

The TCK test DatesMappingTest#testZoneIdMapping tests that ZoneId.of("UTC") is serialized to "UTC", which is not the normalized zone.

martijndwars avatar Mar 14 '20 18:03 martijndwars

For completeness: The ticket https://github.com/eclipse-ee4j/yasson/issues/387 in the Yasson project serves to document this problem in the implementation. The current ticket addresses only the TCK test.

martijndwars avatar Mar 14 '20 18:03 martijndwars