You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow specifying custom DateTimeFormatter for OffsetDateTime ser/deser (new constructors?) #376
Trying to make OffsetDateTime deserialize from ISO_LOCAL_DATE_TIME pattern by appending default offset of "0". This is easily doable with
public static final DateTimeFormatter OFFSET_DATE_TIME_PARSER =
new DateTimeFormatterBuilder()
.append(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
.optionalStart()
.parseLenient()
.appendOffsetId()
.parseStrict()
.optionalEnd()
.parseDefaulting(ChronoField.OFFSET_SECONDS, 0)
.toFormatter();
var parsed = OffsetDateTime.parse("2025-01-01T22:01:05", OFFSET_DATE_TIME_PARSER);
However, there is no easy way to override this parser, especially since InstantDeserializer.ISO_OFFSET_DATE_TIME is created with many parameters and calls methods that are private to the InstantDeserializer.
When looking at LocalDateTimeDeserializer it as a public constructor that accepts DateTimeFormatter as an arg.
Similar situation happens in OffsetDateTimeSerializer. I wish to only display 3 digits of nano-second instead of 9, but there's no right way to override DateTimeFormatter in OffsetDateTimeSerializer like there's in LocalDateTimeSerializer
changed the title [-]Allow specifying OffsetDateTime parser for Serialization/Deserialization[/-][+]Allow specifying custom `DateTimeFormatter` for `OffsetDateTime` ser/deser (new constructors?)[/+]on Oct 23, 2025
Activity
cowtowncoder commentedon Oct 23, 2025
Adding accessible constructor sounds like a reasonable idea.
PRs welcome!
[-]Allow specifying OffsetDateTime parser for Serialization/Deserialization[/-][+]Allow specifying custom `DateTimeFormatter` for `OffsetDateTime` ser/deser (new constructors?)[/+]cowtowncoder commentedon Oct 23, 2025
NOTE: depending on implementation, pr either here (2.x) or jackson-databind (3.x) -- since functionality embedded in databind for Jackson 3.
Fix #376: add factory methods/constructor for OffsetDateTime ser/dese…
cowtowncoder commentedon Nov 17, 2025
Ok: fixing via #379 by:
InstantDeserializer.withDateFormat(DTF)to bepublicOffsetDateTimeSerializer.withFormatter(DTF)so that it is possible to construct customized instances: from unit tests:
(note: did not change existing method name
withDateFormat())cowtowncoder commentedon Nov 17, 2025
Fixed by #379.
Fix FasterXML#376: add factory methods/constructor for OffsetDateTime…