[CONJ-699] Value range of TIME data type not fully supported Created: 2019-04-17  Updated: 2021-05-17  Resolved: 2021-05-17

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC 4.2 compatibility
Affects Version/s: None
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Renat Golubchyk Assignee: Diego Dupin
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

MariaDB Connector/J uses java.sql.Time for TIME columns. TIME columns have a range of '-838:59:59.999999' to '838:59:59.999999'. According to Java documentation "java.sql.Time is a thin wrapper around java.util.Date":

  • An hour is represented by an integer from 0 to 23. Thus, the hour from midnight to 1 a.m. is hour 0, and the hour from noon to 1 p.m. is hour 12.
  • A minute is represented by an integer from 0 to 59 in the usual manner.
  • A second is represented by an integer from 0 to 61; the values 60 and 61 occur only for leap seconds and even then only in Java implementations that actually track leap seconds correctly. Because of the manner in which leap seconds are currently introduced, it is extremely unlikely that two leap seconds will occur in the same minute, but this specification follows the date and time conventions for ISO C.

That means Connector/J supports only a tiny subset of possible values.

How to reproduce:

  1. Create a table with a TIME column
  2. Insert values outside of the range '00:00:00' - '23:59:59'
  3. Try reading them using MariaDB Connector/J


 Comments   
Comment by Diego Dupin [ 2019-09-13 ]

java.sql.Time is limited to 0-24h
if wanting to have time > 24h, you have to use Resultset.getString to have complete value.
example :

        stmt.execute("CREATE TABLE timeTable (t time(6))");
        stmt.execute("INSERT INTO timeTable value ('25:59:59.999999')");
        ResultSet rs = stmt.executeQuery("SELECT * from timeTable");
        rs.next();
        System.out.println(rs.getTime(1)); // 01:59:59 
        System.out.println(rs.getString(1)); // 25:59:59.999999

Comment by Diego Dupin [ 2021-05-17 ]

works as expected

Generated at Thu Feb 08 03:17:40 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.