I have a date attribute in an entity. I have set dateformat to “MM/dd/yyyy” globally.
In the database the date value is stored correctly. When i view the date field in GUI i see one day earlier for the day of the month.
For example in database the date field is stored as “2020-06-19” when I view in GUI date is coming as “2020-06-18”.
Unfortunately, we cannot reproduce the problem. We will be able to help you if you send us a small sample project along with reproduction scenario that demonstrates the issue.
Could you please explain exactly how you solved this problem?
I have the same behavior and do not understand why. My computer (iMac with MacOS 11.1) is set for Central European time (CET), which is the same as GMT+1 or UTC+1 and in mySQL database it appears that the timezone is correct. (Note, please remove the spaces after @ if you use this yourself; I added them here because I could not escape them in this comment.)
Command: SELECT @@ GLOBAL.time_zone, @@ SESSION.time_zone;
Returns: SYSTEM SYSTEM
And in my application “Settings” screen I have tried selecting “Time Zone” -> “Auto” and I have also explicitly set it to “Europe/Zurich (GMT+01:00)”. I live 5km from Zurich.
In my application I use…
TimeSource timeSource = AppBeans. get (TimeSource.class);
publishDate = timeSource.currentTimestamp();
for my variable….
@ Temporal(TemporalType. DATE )
@ Column(name = “PUBLISH_DATE")
protected Date publishDate;
and it is correct when it is immediately displayed after I set it, but in the mySQL database the value is always one day behind. When I reload my screen, I lose 1 day.
I would really appreciate a tip or explanation of why the database value is 1 day behind. Many thanks in advance for your feedback.
Chris and for anyone else who stumbles across this thread,
I had the exact same problem as above. Dates saved as LocalDate were a day behind.
My issue lied in my Data Store Properties where my Connection params included an autofilled property for serverTimezone. Mine was set to UTC when I needed CST.
Edit: I used Cuba Studio to change this property but if you don’t have access to that these params were stored in app.properties in the *core\src* folder. The app property is cuba.dataSource.connectionParams.
Many thanks for the information; I appreciate it. I have migrated to Jmix in the meantime and have not yet retested this particular use case but it is on my TODO list. If I encounter this problem in Jmix and cannot resolve it with your method, then I will update this information here for anyone with this problem that is planning to migrate.