Menu

#139 Milliseconds are not reset to zero when selecting DATE with JDBC

open
nobody
None
5
2012-03-29
2012-03-29
Jira Trac
No

When selecting dates, the java.sql.Date's millisecond part is not correctly reset to zero. Here is a quick example to reproduce the issue:

---------------------------------------------
Connection connection = create().getConnection();

for (int i = 0; i 10; i++) {
ResultSet rs = connection.createStatement().executeQuery(select date '2000-01-01');
rs.next();
System.out.println(rs.getDate(1).getTime());
rs.close();
Thread.sleep(150);
}
---------------------------------------------

The above prints on my machine (CET)

---------------------------------------------
946681200680
946681200838
946681200992
946681200144
946681200298
946681200480
946681200634
946681200787
946681200940
946681200093
}}}
---------------------------------------------

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.