DateFormat formatter = new SimpleDateFormat(\"MM/dd/yyyy\' \'HH:mm:ss\");
Date d = (Date)formatter.parse(dateTime);
System.out.println(\"date in controller \"+d);
>
Need the output in date format and not as string so as to store the output in datetime field in mysql db
After the statement
Date d = (Date)formatter.parse(dateTime);
java.sql.Date sqldate = new java.sql.Date(d.getTime())
you have got a java.util.Date
object and you can store it as it is in mysql DB (column type : datetime).
However, when you are printing d
, it defaults to the .toString()
implementation. I think you expected some output like Date@ but the toString printed in user readable format thats why the confusion.