JDBC Prepared Statement . setDate(….) doesn’t save the time, just the date.. How can I save the time as well?

Instead of Date you should use a Timestamp and the setTimestamp method.

pratically you have to do something like that:

private static java.sql.Timestamp getCurrentTimeStamp() {
    java.util.Date today = new java.util.Date();
    return new java.sql.Timestamp(today.getTime());
}

….

preparedStatement.setTimestamp(4,getCurrentTimeStamp());

Leave a Comment