jackson-modules-java8 icon indicating copy to clipboard operation
jackson-modules-java8 copied to clipboard

Default string formats that will deserialise successfully to an Instant?

Open anthonyleonard opened this issue 5 years ago • 3 comments

What string formats will deserialise successfully to an Instant type, using a vanilla object mapper?

I would like to follow Postels law and be as wide as possible in accepting serialised time formats, but my testers would like to know the range of possible date formats so they can test around it.

Thanks :)

anthonyleonard avatar Mar 28 '19 11:03 anthonyleonard

Seems like this is something that could be documented on README.md either at main level, or for Date/Time module.

Marking as easy for new contributors.

cowtowncoder avatar Aug 13 '19 20:08 cowtowncoder

It appears that only format for string values for property with type java.time.Instant is java.time.format.DateTimeFormatter.ISO_INSTANT Investigated on jackson-datatype-jsr310 version 2.9.0. In this line https://github.com/FasterXML/jackson-modules-java8/blob/2f7d955dbce5bd1e46cd80134aa82cb64b6d684f/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java#L141 used InstantDeserializer which supports only DateTimeFormatter.ISO_INSTANT. Is this worth documenting?

alevskyi avatar Feb 05 '20 15:02 alevskyi

Yes, I think it's worth documenting, and answer's the OP's question:

What string formats will deserialise successfully to an Instant type, using a vanilla object mapper? [snip] my testers would like to know the range of possible date formats so they can test around it.

Now, as where to put the documentation, to answer Cowtowncoder's question,

Seems like this is something that could be documented on README.md either at main level, or for Date/Time module.

my suggestion would be the readme.md for the Date/Time because it seems to have that level of detail:

https://github.com/FasterXML/jackson-modules-java8/tree/master/datetime

kupci avatar Feb 06 '20 20:02 kupci

Looks like README was modified, closing.

cowtowncoder avatar Feb 04 '24 01:02 cowtowncoder