I am using spring boot to create a spring data rest application. I want to use ISO 8601 for serializing/deserializing OffsetDateTimes. I have the following in my @Configuration.
@Bean
public Jackson2ObjectMapperBuilder jacksonBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.indentOutput(false).dateFormat(ISO8601DateFormat.getDateTimeInstance());
return builder;
}
This works for older Date objects, but does not work with OffsetDateTime in Java 8. Is there a standard solution to this, or do I need to write my own JsonSerializers (likely extended from StdScalarSerializer) and add the following:
builder
.deserializerByType(OffsetDateTime.class, myCustomOffsetDateTimeDeserializer)
.serializerByType(OffsetDateTime.class, myCustomOffsetDateTimeSerializer)
I feel like there must be some standard serializers/deserializers out there for these objects that I'm missing. Are there?