我在json对象中有一个字符串字段,该字符串字段以以下格式表示日期:2019-04-09T16:29:25Z
当然用双引号引起来。
pratica.put(“ dataCreazionePratica”,OffsetDateTime.parse(“ 2019-04-09T16:29:25Z”));
然后,我使用Jackson ObjectMapper
将JSON映射到一个对象,该日期为OffsetDateTime
对象。我收到以下错误:
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')
我不理解为什么在错误消息中我得到了单引号。我试图像这样更改json对象:
pratica.put(“ dataCreazionePratica”,OffsetDateTime.parse(“ 2019-04-09T16:29:25Z”));
但随后出现以下错误:
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)
就好像它试图将其读取为整数一样……是否还有其他方法可以解析字符串日期并获取OffsetDateTime?