Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring jpa hibernate mysql LocalDate off one day after persist

Whenever I persist LocalDate to MySQL Database, the Date is stored one day off (11 Nov 2017 becomes 10 Nov 2017). I've already tried to set the timezone in the application on MySQL server and set the legacyDateTimeCode to false but the problem still exists. Any idea on how to fix it? If I switch to local h2 Database, the Date is stored correctly.

Spring-boot-starter-parent: 1.5.7 hibernate 5.2.10 mysql: 5.7 LocalDate stored in DATE field

like image 382
Ceryni Avatar asked Nov 10 '17 17:11

Ceryni


1 Answers

Add spring.jpa.properties.hibernate.jdbc.time_zone : UTC In Properties file

like image 183
Naveen Avatar answered Sep 16 '22 13:09

Naveen