Java.sql.Date to Oracle database Date and Timestamp
date, jdbc, spring, sql
Solution
You need to use `java.sql.Timestamp`
bean.setStartTime(new java.sql.Timestamp(...))
`java.sql.Date` removes the time part
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.
Problem
I am using Spring JDBC template for jdbc operations. Since I am using BeanPropertySqlParameterSource, the bean's START_TIME variables is assigned with java.sql.date type. in Oracle db, the column is mentioned as "DATE" type (and don't have TIMESTAMP type, even the db is 10.2 ver) Now when I set ``` bean.setStartTime(new Date(System.currentTime()) ``` it's storing with date and time stamp as 00:00:00 Please tell me how can i Store the time stamp also.