I have string field in a json object that represents a date in the following format: 2019-04-09T16:29:25Z
wrapped in double quotes, of course.
pratica.put("dataCreazionePratica", OffsetDateTime.parse("2019-04-09T16:29:25Z"));
I then use Jackson ObjectMapper
to map my JSON to an object, that for said date is an OffsetDateTime
object. I get the following error:
Cannot construct instance of `java.time.OffsetDateTime` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('2019-04-09T16:29:25Z')
I do not undertand why in the error message I got the single quotes. I tried to change my json object like this:
pratica.put("dataCreazionePratica", OffsetDateTime.parse("2019-04-09T16:29:25Z"));
but then I got the following error:
Cannot construct instance of `java.time.OffsetDateTime` (no Creators, like default construct, exist): no int/Int-argument constructor/factory method to deserialize from Number value (2019)
It's like it's trying to read it as an integer... Is there any other way to parse a string date and obtain an OffsetDateTime?