I want to insert the current Date into my table.
I need to convert a java.util.Date to a java.sql.Date. The date in my database colum is of type Timestamp.
java.util.Date today = new java.util.Date();
SimpleDateFormat shortDateFormat = new SimpleDateFormat("dd/MM/yyyy");
String date = today.toString();
try{
myDate = new java.sql.Date(shortDateFormat.parse(date).getTime());
}
catch(Exception e){
e.printStackTrace();
}
On trying to insert I get this error:
java.text.ParseException: Unparseable date: "Mon Jun 26 12:46:54 GMT+02:00 2006"