Skip to content

Add support for serializing JSR 310 time types #739

@ColdFerrin

Description

@ColdFerrin

Currently, when you serialize the JSON with JsonSerializer.class, it converts the JSR 310 time types to their internal fields. If you add one dependency and configure the serializer, it will allow you to write the JSR 310 types DateTime, LocalDate, and LocalTime out as their appropriate ISO8601 representations.

The needed dependency is

<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jsr310</artifactId>
    <version>{Current Version}</version>
</dependency>

The serializer feature that you will need to add is

new ObjectMapper()
            .registerModule(new JavaTimeModule());

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions