Convert String to Date Object in Java

date, java

Solution

Make it

DateFormat df = new SimpleDateFormat("MMM dd yyyy HH:mm:ss");

Note: `MMM`

Problem

I need to parse the following string into a date object in java: ``` String time = "Jul 24 2012 05:19:34"; DateFormat df = new SimpleDateFormat("MM dd yyyy HH:mm:ss"); Date date = df.parse(time); ``` The code throws this exception: ``` Unparseable date: "Jul 24 2012 05:19:34" ``` Does anyone know how to fix this?

Original source