I'm developing a spring boot application that handles dates. When I submit an Appointment object that has a startDateTime
and an endDateTime
(Both are of type java.util.Date
) I send a format like this:
{
"lastName": "Jhon",
"firstName": "Doe",
"email": "[email protected]",
"description": "MyDescription",
"startDateTime": "2017-10-09T22:43:07.109+0300",
"endDateTime": "2017-10-09T21:40:07.109+0300",
}
When data is persisted in database it's with the correct timezone, when I try to retrieve my data back, they seem correct when I'm debugging however, once they are serialized by Jackson I have an output with these as value:
"startDateTime": "2017-10-09T19:43:07.109+0000",
"endDateTime": "2017-10-09T18:40:07.109+0000",
How can I configure Jackson to make usage of timezone that comes with the data from my repository?
------Update---------
I tried the answer with OffsetDateTime
but the output is quite weird:
"startDateTime": {
"offset": {
"totalSeconds": 7200,
"id": "+02:00",
"rules": {
"fixedOffset": true,
"transitionRules": [],
"transitions": []
}
},
"month": "OCTOBER",
"year": 2017,
"hour": 21,
"minute": 49,
"nano": 654000000,
"second": 15,
"dayOfMonth": 9,
"dayOfWeek": "MONDAY",
"dayOfYear": 282,
"monthValue": 10
}
I would like to have something like:
2017-10-09T22:43:07.109+0300
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With