FasterXML / jackson-modules-java8

Set of support modules for Java 8 datatypes (Optionals, date/time) and features (parameter names)
Apache License 2.0
401 stars 117 forks source link

Default string formats that will deserialise successfully to an Instant? #108

Closed anthonyleonard closed 9 months ago

anthonyleonard commented 5 years ago

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 :)

cowtowncoder commented 5 years ago

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.

alevskyi commented 4 years ago

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?

kupci commented 4 years ago

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

cowtowncoder commented 9 months ago

Looks like README was modified, closing.