I have been used Spring Date Rest with Spring Boot in my project. This project has a object and I have used the annotation @JsonFormat to format the date field that will be received from my Json. The format of field Date is "dd/MM/yyyy". When I send in my json the value "08/07/1980" the Jackson convert to the value "07/07/1980".
The problem is that @JsonFormat set the date with one day less
This is my source code
@Temporal(TemporalType.DATE)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy", locale = "pt-BR", timezone = "UTC")
private Date birthDate;
Thanks
On both side (Client - Server) annotate your date filed like this:
and on both side again put this implementations for serializing and deserializing:
@William's answer works but you should add theses lines to your application.properties files instead:
In that way, you indicate the time-zone and locale only one time, and it applicate to all the Date of your application.
Hey guys use this solution, it is more effective and modern than my solution.
https://stackoverflow.com/a/45456037/4886918
Thanks @Benjamin Lucidarme
I resolved my problem using:
I changed timezone to "Brazil/East" or "America/Sao_Paulo" and working now
Thanks
I'd go with setting
ObjectMapper
timezone as default JVM timezone:It's a better solution if you don't know what timezone is used on a server environment.