JsonFormat changing date in a get request

0

I have a web service in java using Spring Boot, in a class I have an attribute of type date and I use JsonFormat to format the date and be able to convert on the client side, using Gson. However, even setting the locale for the zone of Brazil, which would be UTC-03, it converts to three hours more, making the date different. How do I resolve this issue?

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", locale = "UTC-03")
private Date date;
    
asked by anonymous 09.04.2017 / 01:09

1 answer

2
  

However, even setting the locale for the Brazilian zone, which would be UTC-03

Actually, the locale has another meaning .

Try changing the annotation to set the timezone :

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone="GMT-3")
private Date date;
    
09.04.2017 / 03:07