MariaDB Connector/J 1.3.0 Release notes
You are viewing an old version of this article. View
the current version here.
Download Release Notes Changelog Connector/J Overview
Beta Release date: 29 Sep 2015
MariaDB Connector/J 1.3.0 is a Beta release.
For a description of the MariaDB Connector/J see the About the MariaDB Connector/J page.
new Date/Time/Timestamps implementation that handle timezone and daylight correctly.
A new parameter is added :
useLegacyDatetimeCode | if false (recommended if new database), use serverTime zone when storing Date/Time/Timestamps default to true |
---|
when using useLegacyDatetimeCode=false, all Time/Date/Timestamps object are stored in ServerTime zone, taking daylight in account. Exemple : exemple with some particular timezone: Paris is GMT+1 before 2015-2-29 01:00:00, and GMT+2 after.
UTC TIME | PARIS TIME | CANADA TIME |
---|---|---|
2015- 2- 29T00:45:00+0000 | 2015- 2- 29T01:45:00+1000 | 2015- 2- 28 21:45:00-3000 |
2015- 2- 29T01:15:00+0000 | 2015- 2- 29T03:15:00+1000 | 2015- 2- 28 22:15:00-3000 |
If Java client is using "Europe/Paris" timezone, server "Canada/Atlantic" (UTC recommended, but not mandatory). when So with a java code
connection.createStatement().execute("CREATE TABLE daylight (t1 TIMESTAMP(6), t2 DATETIME(6))"); PreparedStatement pst = connection.prepareStatement("INSERT INTO daylight VALUES (?, ?)"); pst.setTimestamp(1, Timestamp.valueOf("2015-03-29 01:45:00")); pst.setTimestamp(2, Timestamp.valueOf("2015-03-29 01:45:00")); pst.addBatch(); pst.setTimestamp(1, Timestamp.valueOf("2015-03-29 02:15:00")); pst.setTimestamp(2, Timestamp.valueOf("2015-03-29 02:15:00"));
the database will have
t1 | t2 |
---|---|
2015-03-28 21:45:00.000000 | 2015-03-28 21:45:00.000000 |
2015-03-28 22:15:00.000000 | 2015-03-28 22:15:00.000000 |
ResultSet res = connection.createStatement().executeQuery("SELECT * FROM daylight"); res.next(); assertEquals(res.getTimestamp(1),Timestamp.valueOf("2015-03-29 01:45:00")); assertEquals(res.getTimestamp(2),Timestamp.valueOf("2015-03-29 01:45:00")); res.next(); assertEquals(res.getTimestamp(1),Timestamp.valueOf("2015-03-29 03:15:00")); assertEquals(res.getTimestamp(2),Timestamp.valueOf("2015-03-29 03:15:00"));
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.