Calendar cal;
String sql = "INSERT INTO ttable (dt) values (?);"
//dt is a dateTime field in ttable
PreparedStatement stmt = connection.prepareStatement(sql);
stmt = setDate(1,cal); //not working
stmt.execute();
stmt.close();
I would like to convert cal to a Date type to insert into table.
There is a
getTime()method (unsure why it’s not called getDate).Edit: Just realized you need a java.sql.Date. One of the answers which use
cal.getTimeInMillis()is what you need.