0

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 :)

7
  • 1
    What exception do you get? Commented Apr 29, 2013 at 21:12
  • java.text.ParseException: Unparseable date: "Wed, 4 Jul 2001 12:08:56 -0700" Commented Apr 29, 2013 at 21:16
  • Could it be that MMM doesn't mean Jul that it could be expecting 07 ? Commented Apr 29, 2013 at 21:18
  • is -0700 correct, did you try it without it? Commented Apr 29, 2013 at 21:18
  • 1
    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. Commented Apr 29, 2013 at 21:19

1 Answer 1

0

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")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.