[CONJ-94] SQL DATEs stored wrong if client timezone is east of server timezone Created: 2014-04-24 Updated: 2015-09-18 Resolved: 2015-09-18 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | Other |
| Affects Version/s: | 1.1.7 |
| Fix Version/s: | 1.3.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Pasi Eronen | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Sprint: | Sprint connector/j 1.3.0 |
| Description |
|
The SQL DATE type is just plain year/month/day (without hours/minutes/etc), and in MariaDB, it does not include a time zone. Thus, writing a java.sql.Date to a DATE column (or reading a DATE column to java.sql.Date) should not depend on client or server time zones. Time zone differences are expressed in hours, and you can't really add or subtract one hour to a plain date that does not have an hours part. (Note that the situation for writing a java.util.Date to a DATE column might be different, and might sensibly depend on some time zones.) The current behavior causes wrong behavior when the server timezone is west of the client timezone. The test program below (when server is UTC and client is Europe/Helsinki) attempts to store 2013-11-20 to the database, but reads back 2013-11-19.
Proposed fix:
BTW, the MySQL Connector/J driver has a similar bug, but that's trickier to fix since there's shared code between java.sql.Dates (without time) and java.util.Dates (with time). See http://bugs.mysql.com/bug.php?id=71084 |
| Comments |
| Comment by Rasmus Johansson (Inactive) [ 2015-06-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Please verify if this bug still exists (I think it does) and try to fix | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Diego Dupin [ 2015-09-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
reproduced, and corrected in the next version 1.3.0.
and in binary format (for preparedStatement) other way (using calendar was 20 time less performant )
retreiving data is using a deprecated method that will have to wait end of life of java 7 to permit use java 8 yoda time implementation.
tests added( for server and client query)
|