I have a code in Spring with java 8 to insert the current date and time in my Mysql 5.7 database, the problem is that when I check the database it adds one more hour to the one that corresponds, the data type in the database is Datetime.
I already checked the time_zone in Mysql with SELECT @@ time_zone and it shows me: + ------------- + | @@ time_zone | + ------------- + | SYSTEM | + ------------- +
and also select now (); and it shows me the current time correctly.
My code is the following:
The class where I implement it:
LocalDateTime actual = LocalDateTime.now();
DTO.getPer().setDateUpdate(actual);
In the model:
@Column(name = "date_update")
private LocalDateTime dateUpdate;
Thank you.