I’m trying to convert following text to Date but not able to get it to parse correctly.
String strDate = "Tue Mar 13 12:00:00 EST 2012";
try{
SimpleDateFormat sd = new SimpleDateFormat("dd/MM/yyyy");
//also tried SimpleDateFormat sd = new SimpleDateFormat("dd/MM/yyyy HH:mm");
//as well as sd.setTimeZone(TimeZone.getDefault());
Date date = sd.parse(strDate);
}catch(Exception e)
{
e.printStack();
//fails with java.text.ParseException: Unparseable date: "Tue Mar 13 12:00:00 EST 2012"
}
what am i doing wrong?
Try using a date format that matches the input.
edit: fixed the date format string.
Note: HH is hour in day not am/pm hour.