-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Milestone
Description
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
Would you kindly support this use-case?
Metadata
Metadata
Assignees
Labels
No labels