0
votes

I'm currently trying to parse a date, and I took the following example from the javadoc (http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) :

Format : "EEE, d MMM yyyy HH:mm:ss Z" Date : Wed, 4 Jul 2001 12:08:56 -0700

To parse this date I'm currently doing the following :

new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z").parse("Wed, 4 Jul 2001 12:08:56 -0700")

But I get an exception

java.text.ParseException: Unparseable date: "Wed, 4 Jul 2001 12:08:56 -0700"

. What am I doing wrong ?

Thanks a lot for your help :)

1
What exception do you get?Kenster
java.text.ParseException: Unparseable date: "Wed, 4 Jul 2001 12:08:56 -0700"Nisalon
Could it be that MMM doesn't mean Jul that it could be expecting 07 ?ddavison
is -0700 correct, did you try it without it?iberbeu
What's your locale? (print is with System.out.println(Locale.getDefault())). If you're let's say, in a French locale, then this english date won't be parseable.JB Nizet

1 Answers

0
votes

Solved :

I have to specify the locale, since the locale of my computer is not en_US :

new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH).parse("Wed, 4 Jul 2001 12:08:56 -0700")