| Bug #99487 | Mysql connector for java 8.0.20 shifts back LocalDate by one day when queried | ||
|---|---|---|---|
| Submitted: | 8 May 2020 10:39 | Modified: | 12 May 2020 10:04 |
| Reporter: | Martin Soukup | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 8.0.20 | OS: | Linux |
| Assigned to: | CPU Architecture: | x86 | |
| Tags: | MySql Connector, spring boot | ||
[8 May 2020 10:41]
Martin Soukup
This issue doesnt occur on version 8.0.19
[12 May 2020 8:14]
Alexander Soklakov
Hi Martin, If it was working for you with c/J 8.0.19 then it must be the consequences of the Bug#91112 fix. In c/J 8.0.20 LocalDate is rendered using the local JVM time zone which is altered in @PostConstruct. But the driver can follow this change only when cacheDefaultTimezone=false. We have other issues with LocalDate/LocalTime/LocalDatetime reported in Bug#93444, so if setting cacheDefaultTimezone=false doesn't help then it's a duplicate bug for Bug#93444.
[12 May 2020 8:28]
Martin Soukup
Hi, I added cacheDefaultTimezone=false and now I dont get this error on 8.0.20. Thanks
[12 May 2020 10:04]
Alexander Soklakov
Thanks for checking!

Description: Hi, I have run into following issue after updating spring boot from 2.2.6 to 2.2.7: When I save LocalDate with spring data jpa repository to mysql - for example: 2020-05-08, it is correctly written to database as 2020-05-08. But when I later want to retrieve it with the repository what I get back is shifted by one day backwards: 2020-05-07. This started to happen only after this update. I made sure that the database is set to UTC: image And I also set the application to the same timezone: @ConfigurationPropertiesScan @EnableScheduling @SpringBootApplication class EconomyApplication { @PostConstruct fun init() { TimeZone.setDefault(TimeZone.getTimeZone("UTC")) } } This problem is also described previously by someone on stackoverflow: https://stackoverflow.com/questions/54418827/mysql-date-changes-to-yesterdays-date-after-j... How to repeat: Save java LocalDate with spring data jpa and then retrieve it back - it will be shifted by one day backwards