Skip to content
Advertisement

OffsetDateTime always converted to UTC

I’m having a very simple spring boot app that gets and returns a timestamp.

The code is as follow:

Controller

JavaScript

Model

JavaScript

I’ve noticed that when I’m sending timezones which are not UTC the object I’m receiving converted into UTC – for example, the following call:

JavaScript

has this response:

JavaScript

Is there a way to disable this behavior and receive the time as it was send?

Advertisement

Answer

This happens because Jackson is using context default timezone when deserializing. In Spring-Boot you can disable this quite easily, by just adding:

spring.jackson.deserialization.adjust-dates-to-context-time-zone=false

to your application.properties.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement