Which timezone applies when OffsetDateTime and ZonedDateTime are serialized in Dropwizard without explicit configuration?
0 reputation · 02 Jan 2025, 18:27 UTC
When Dropwizard resources serialize date-time fields using Jackson, the ObjectMapper's default timezone resolution depends on whether an explicit TimeZone has been set in the Environment configuration. If none is provided, the JVM's system default is used, which may differ across deployment targets and affect the format of serialized date-time values.
The choice between OffsetDateTime and ZonedDateTime further complicates consistency: OffsetDateTime outputs an offset-from-UTC string such as '+01:00', while ZonedDateTime includes a zone ID like 'Europe/Paris'. Without explicit configuration, both types may resolve to different string representations for the same instant, creating non-deterministic API responses when the service runs in regions with varying timezone settings.
Which timezone takes precedence when both date-time types appear in the same resource? Does the presence of the Jackson8TimeModule change the default resolution path? How does this behavior impact client expectations for deterministic ISO-8601 timestamps across regions?