Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-719

Saving values using Java 8 LocalTime does not store fractional parts of seconds

    Details

      Description

      When using java.time.LocalTime to store values in DB, org.mariadb.jdbc.BasePrepareStatement loses all the fractional parts of the seconds during the conversion to java.sql.Time and then uses that to store the value. Even if the conversion was done correctly, java.sql.Time only allows storing at millisecond precision, so some data would be lost in any case.

      There are proper implementations with correct fractional second support for OffsetDateTime, OffsetTime and ZonedDateTime so I assume this is just an oversight that LocalTime was not supported with fractions support? If it was intentional, then it would still make sense to keep at least millisecond precision which is also supported using the legacy java.sql.Time datatype.

      It is possible to work around the issue atm by implementing a custom org.mariadb.jdbc.internal.com.send.parameters.ParameterHolder and using that to set the value using org.mariadb.jdbc.BasePrepareStatement.setParameter()

        Attachments

          Activity

            People

            • Assignee:
              diego dupin Diego Dupin
              Reporter:
              tarmo Tarmo Randma
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: