Bug #49759 | java.util.Date gets a Timezone conversion applied in reads but not in writes | ||
---|---|---|---|
Submitted: | 17 Dec 2009 8:04 | Modified: | 29 Apr 2015 12:02 |
Reporter: | Fred Janon | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / J | Severity: | S1 (Critical) |
Version: | 5.1.10 | OS: | Windows (XP) |
Assigned to: | Alexander Soklakov | CPU Architecture: | Any |
[17 Dec 2009 8:04]
Fred Janon
[21 Dec 2009 10:40]
Tonci Grgin
Hi Fred and thanks for your report. There might be a bug here as we've seen such troubles before. Thus we decided to completely avoid storing DATE information as a MySQL Date, but rather store a java "date" of milliseconds since epoc in a bigint20 field. So, best advice regarding this would be not to store a java Date as a Date, but to store the java Date.getTime() which returns the "long" value. Now, there is a comprehensive Date test suite in our sources so if you'll just take some time and look into testsuite/simple/DateTest.java and see if it helps. If not, please attach complete test case so I can check.
[22 Dec 2009 8:01]
Tonci Grgin
Mark, could this be related to Bug#49700?
[22 Jan 2010 0:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[29 Apr 2015 12:02]
Filipe Silva
Hi Fred, This report isn't clear enough to confirm for sure the described behavior, however, it looks a lot like it is related to how and when you reset the reset the system's default time zone. I. e., if you call "TimeZone.setDefaultTimeZone()" before creating connections then all should work fine, but, if you change it after, then you should set the connection property "dynamicCalendars=true" in order to make the driver aware of these changes, otherwise a wrong Calendar instance would be used when creating your date values causing the conversion you are observing. Thank you,