I’m writing an app which is trying (and failing) to parse a date in the following format: Fri, 22 Jul 2011 04:14:43 -0700
The code I’m using to try and parse it is as follows:
Calendar pubDate = Calendar.getInstance();
pubDate.setTime(new SimpleDateFormat().parse(dateString));
The exception I’m getting is:
java.text.ParseException: Unparseable date: Fri, 22 Jul 2011 04:14:43 -0700
I have absolutely no control over the date data or it’s format. Any ideas what I’m missing here?
If the date’s always going to be in that format, you could try passing a pattern to SimpleDateFormat rather than using the default constructer:
pubDate.setTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z").parse(dateString));