I have an entity that has a date field:
import java.util.Date;
...
@Basic(optional = false)
@Column(name = "ora_programare")
@Temporal(TemporalType.TIMESTAMP)
private Date oraProgramare;
In my rest controller, I print the value of this field right before the end of the function that handles my entry point and I can see that the value for the date field is
oraProgramare=2023-08-01 08:30:00.0
But in POSTMAN I receive a different date:
"oraProgramare": "2023-08-01T05:00:00.000+00:00"
All dates are changed by 3 hours and 30 minutes, why?
UPDATE: I found a solution here, if I annotate the field with
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss",timezone="Europe/Bucharest")
then the hour is correct but I don't understand, my default time zone is "Europe/Bucharest", why is Spring allocating the wrong timezone? I checked my default timezone using:
System.out.println("ZoneId.systemDefault() "+ZoneId.systemDefault());
But is complicated to annotate all the datetime fields, I will try to change the type from Date to LocalDateTime