DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy' 'HH:mm:ss");
Date d = (Date)formatter.parse(dateTime);
System.out.println("date in controller "+d);
I get the output as
date in controller Mon Dec 31 16:04:57 IST 2012
Please suggest a method to output the date in MM/dd/yyyy HH:mm:ss format.
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
you have got a
java.util.Dateobject 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.