How come that java.sql.PreparedStatement#setDate on dateTime mysql column always results in Date format like 2012-10-16 00:00:00 without Time information ? I’m storing Date in a loop like this :
protected Date getIncrementedDateTime() {
additionalTime += 1000;
return new Date(System.currentTimeMillis() + additionalTime);
}
preparedStatement.setDate(j, new java.sql.Date(getIncrementedDateTime().getTime());
I debugged the values, but mysql database always have 2012-10-16 00:00:00 values.
As per the documentation for
java.sql.Date:Basically, for a datetime column you should probably be using a different type, e.g.
Timestamp. (That’s not ideal in other ways, but it’s likely to be a better fit…)