#681 support for datetimeoffset


JTDS currently doesn't support datetimeoffset datatype introduced in MSSQL 2008.

Shortened stacktrace when calling ResultSet.getTimestamp(int) is:

java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
    at java.sql.Timestamp.valueOf(Timestamp.java:249)
    at net.sourceforge.jtds.jdbc.Support.convert(Support.java:480)
    at net.sourceforge.jtds.jdbc.JtdsResultSet.getTimestamp(JtdsResultSet.java:1163)
    at net.sourceforge.jtds.jdbc.JtdsResultSet.getTimestamp(JtdsResultSet.java:1315)

keywords: locale date time datetime offset datetimeoffset timezone


Discussion: Support for datetimeoffset in SQLServer
Discussion: JTDS support for MSSQL2008 datetimeoffset


  • Jakub Neubauer

    Jakub Neubauer - 2012-11-09

    Additional info to think about regarding the possible implementation of datetimeoffset is mentioned in forum https://sourceforge.net/p/jtds/discussion/104389/thread/99808c0f/#d94b:

    We call PrepareStatement.setTimestamp(index,java.sql.TimeStamp) that using
    local TimeZone, it seems that there is no TimeZone offset consideration for
    datetimeoffset column in jtds jdbc driver.

    For example: Our local TimeZone is GMT+08:00 and the local date is "2011-12-11
    13:14:15". Then we construct a java.util.Date Object from it. Second,we
    consturct java.sql.TimeStamp(java.util.Date.getTime()).

    But the result is "2011-12-11 13:14:15.0000000 +00:00" in DB, it is not right.

    So that is our use error or that is a JTDS bug. We think JTDS need to import
    datetimeoffset type support.

  • Arek

    Arek - 2016-04-11

    Handling datetimeoffset datatype gained importance especially when working with SQL Server as a Microsoft Azure cloud service. Note from MSDN: "These uses for DateTimeOffset values are much more common than those for DateTime values. As a result, DateTimeOffset should be considered the default date and time type for application development". Unfortunately, almost four years later, last version of driver (jTDS 1.3.1) still does not support this type of data.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks