Api is returning json having date in format of
{
"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
}
}
How to parse this json into util.Date or Joda DateTime? We have added CustomDateDeserializer. But challenge is to map this format into object through jackson. Gson is successfully able to parse this.
This looks like the default serialization of a LocalDate
if the proper serializer is not included.
If you can talk to the provider and get them to fix this output (include the LocalDate
serializer from Jackson) then do that. It make everyone's life easier.
Otherwise, you can just extract the year
, monthOfYear
and dayOfMonth
and create a LocalDate
from these fields.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.