I have a date string in the following format:
Thu Oct 20 14:39:19 PST 2011
I would like to parse it using DateFormat to get a Date object. I’m trying it like this:
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
Date date = df.parse(dateString);
This gives a ParseException (“unparseable date”).
I’ve also tried this:
SimpleDateFormat df = new SimpleDateFormat("EEE-MMM-dd HH:mm:ss z yyyy");
with the same results.
Is that the right SimpleDateFormat string? Is there a better way to parse this date?
The issue was that I was trying to parse an English date while in the French locale.
This was resolved by using this instead:
SimpleDateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.CANADA);