3

I have an exception in parsing a date from a string:

java.text.ParseException: Unparseable date: "16 May 2013 19:27:12" (at offset 3)

but i think that i'm using the right pattern:

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

try {
    done = true;
    date = simpleDateFormat.parse(dateString);
} catch (ParseException e) {
    e.printStackTrace();
    done = false;
}
if (done) {
    return date;
}

Somebody can help? What am I doing wrong?

1 Answer 1

12

The problem is the interpretation of "May" because you did not specify any locale.

Try :

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy HH:mm:ss", new Locale("en_US"));
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.