I have a table in SQL Server with a column type smalldatetime and I am using PreparedStatement to read/write data in my tables. E.g My table is like:
| date |
+------------------------+
| 2019-11-06 09:48:00 +
| 2019-11-05 07:04:00 +
| ... +
+------------------------+
and I am reading the column date with:
String date = rs.getString("date");
And I get an extra .0 at the end of the date:
2019-11-06 09:48:00.0
2019-11-05 07:04:00.0
Why is this happening?
The underlying
SQL ServerJDBC driver converts the returned bytes into aGregorianCalendarfirst and then callstoStringon a newly createdTimestampbased on thisGregorianCalendar. This causes the trailing.0.mssql-jdbc Conversion Code mssql-jdbc SMALLDATETIME handling
So what the mssql-jdbc code actually executes is:
JavaDoc Timestamp#toString