Api正在返回具有格式为的日期的json
{
"modifiedDate": {
"dayOfWeek": 2,
"dayOfYear": 172,
"year": 2022,
"dayOfMonth": 21,
"era": 1,
"monthOfYear": 6,
"millisOfDay": 12144237,
"hourOfDay": 3,
"minuteOfHour": 22,
"secondOfMinute": 24,
"millisOfSecond": 237,
"weekOfWeekyear": 25,
"weekyear": 2022,
"yearOfEra": 2022,
"yearOfCentury": 22,
"centuryOfEra": 20,
"secondOfDay": 12144,
"minuteOfDay": 202,
"zone": {
"fixed": true,
"id": "Etc/UTC"
},
"chronology": {
"zone": {
"fixed": true,
"id": "Etc/UTC"
}
},
"millis": 1655781744237,
"afterNow": false,
"beforeNow": true,
"equalNow": false
}
}
如何将此json解析为util.Date或Joda DateTime?我们添加了CustomDateDeserializer。但挑战是通过Jackson将此格式Map为对象。Gson能够成功解析此格式。
1条答案
按热度按时间2ledvvac1#
如果没有包含正确的序列化程序,这看起来像是
LocalDate
的默认序列化。如果你能和提供商谈谈,让他们修复这个输出(包括来自Jackson的
LocalDate
序列化器),那么就去做吧。这会让每个人的生活更轻松。否则,您可以只提取
year
、monthOfYear
和dayOfMonth
,并从这些字段创建一个LocalDate
。