I am getting date from database as 2013-05-03 00:20:29.0. I want to parse the date to EEE MMM dd HH:mm:ss zzz yyyy format, but when I am parsing it, I am getting this exception:
java.text.ParseException: Unparseable date: "2013-05-03 00:20:29.0"
My code is below:
String createdDate = "2013-05-03 00:20:29.0";
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
Date parseDate = format.parse(createdDate);
You have to adjust the Format pattern. Format must be yyyy-MM-dd HH:mm:ss.S
Try this
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
See http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With