I am getting this Date as String
String str = "Fri May 13 2011 19:59:09 GMT 0530 (India Standard Time)";
How to convert this Date Object into the format: yyyy-mm-dd HH24:Mi:ss?
I have not seen any example using SimpleDateFormat with this format.
You need to parse it into a
Datefirst usingSimpleDateFormat.Then, you can format it using another
SimpleDateFormatinstance.Unrelated to the problem, I however wonder where the original string is coming from. It look much like the result of
date.toString(). Are you sure you’re doing things the right way? Date should be stored and transferred asjava.util.Dateand not asjava.lang.String. You should only convert it toStringat exactly the point whenever you want to display it to the enduser.