I am using following code to insert a java.util.Date
object in MySQL. d1
is date object I'm getting from a function. I tried casting java.util.Date
into java.sql.Date
but this doesn't save the time part.
String sql = "INSERT INTO abc " +
"VALUES" + "('Zara',?)";
pstmt = conn.prepareStatement(sql);
pstmt.setDate(1, d1);
stmt.executeUpdate(sql);
Any Idea to store Date and time of Date Object in MySQL?