'Spring Jackson java.util.Date issue

I am using Spring boot( > 2.3) + Jackson in my application. I have POJO class and have java.util.date property in it. I have an REST api exposed on this POJO. Now when I receive the response from Spring boot the Date property value is converted to UTC everytime.

To fix this I have an option to set @JsonFormat(timestamp="ist"), this can be done. But in my case I cannot provide this option as my project is not running in IST.Now i tried to create a Deserializer class and annotated with @JsonComponent. Even this is not picking while deserialization.

If I try with LocaldateTime, issue fix can be achieved. But in all project I am using java.util.date and have no time to change in all places. Also I tried to @Autowire ObjectMapper and set the timezone to the same. But just before sending the response i tried to print the response in the log and data is fine and correct but when spring send the response back to client the date changes to UTC.

Anyone please help me out....



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source