+-

我正在使用 Spring JDBC模板进行jdbc操作.
由于我使用的是BeanPropertySqlParameterSource,因此bean的START_TIME变量分配了java.sql.date类型.
在Oracle db中,该列被称为“DATE”类型(并且没有TIMESTAMP类型,即使db是10.2 ver)
由于我使用的是BeanPropertySqlParameterSource,因此bean的START_TIME变量分配了java.sql.date类型.
在Oracle db中,该列被称为“DATE”类型(并且没有TIMESTAMP类型,即使db是10.2 ver)
现在,当我设置
bean.setStartTime(new Date(System.currentTime())
它以日期和时间戳存储为00:00:00
请告诉我如何存储时间戳.
最佳答案
您需要使用java.sql.Timestamp
bean.setStartTime(new java.sql.Timestamp(...))
java.sql.Date删除时间部分
From the Javadocs:
To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be ‘normalized’ by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated.
点击查看更多相关文章
转载注明原文:Java.sql.Date到Oracle数据库的日期和时间戳 - 乐贴网