Reputation: 57
I'm trying to retrieve objects with a date field via a get request to my spring boot app. The dates are correct in the database, correct when debugging, but are altered by 1 hour when jackson deserializes them.
in class
@JsonFormat(pattern = "dd-MM-yyyy HH:mm")
private Date matchDate;
In application.properties
spring.jackson.deserialization.adjust-dates-to-context-time-zone=false
I have no idea why it is altering them, I want jackson to deserialise the dates exactly as they are
Upvotes: 1
Views: 721
Reputation: 30088
The documentation for that setting says,
"If enabled, contextual TimeZone will essentially override any other TimeZone information; if disabled, it will only be used if value itself does not contain any TimeZone information."
So, since your serialized format does not indicate a time zone, that setting will have no effect on your deserialization.
My suggestion is, if possible, always include a time zone when passing serialized dates around - that way, there is no question about how to interpret the value.
Upvotes: 1