Skip to content

java.sql.Date is not a real date

java.sql.Date stores only date information, not times. Converting a java.util.Date into a java.sql.Date will silently set the time to midnight. To store the date and time values to be manipulated (e.g. cases when you’re trying to calculate the Epoch/ UNIX time) as java.util.Date objects try using the following:

preparedStatement.setTimestamp(1, new java.sql.Timestamp(date.getTime()));

Read more at java.sql.Date is not a real date