Skip to content
Discussion options

You must be logged in to vote

Java 8 Date/Time, including Instant is built-in for Jackson 3. Note that DateFormat is only for java.util.Date / Calendar; Java 8 types cannot use that class for config.

But do not try registering Instant handlers separately; Config Overrides with JsonFormat.Value.forPattern() is the way to go. I do not remember call off-hand but there are unit tests for it, f.ex src/test/java/tools/jackson/databind/ext/javatime/deser/InstantDeserTest.java:

ObjectMapper mapper = JsonMapper.builder()
    .withConfigOverride(Instant.class,
      o -> o.setFormat(JsonFormat.Value.forPattern(<MY INSTANT PATTERN>))
   .build();

and so on for other types

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@ledents
Comment options

@cowtowncoder
Comment options

Comment options

You must be logged in to vote
2 replies
@ledents
Comment options

@cowtowncoder
Comment options

Answer selected by ledents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants