0

I want to convert this date "Sat, 16 Nov 2013 20:09:07" to unixtime

my code

SimpleDateFormat pattern = new SimpleDateFormat("EEE, dd MM yyyy HH:mm:ss");
Date date = pattern.parse("Sat, 16 Nov 2013 20:09:07")
long milliseconds = date.getTime();

i got this exception

 java.text.ParseException: Unparseable date: "Sat, 16 Nov 2013 20:09:07"
 (at offset 8)
at java.text.DateFormat.parse(DateFormat.java:555)

is there a problem with the pattern ??

0

1 Answer 1

5

Yes - you're using MM which is a numeric month pattern. You want MMM instead, as that's "abbreviated month name". I'd also suggest explicitly specifying Locale.US in the SimpleDateFormat constructor if you know that the month and day names will be in English (otherwise it'll use the system default locale).

Sign up to request clarification or add additional context in comments.

1 Comment

You are one of the greatest resources in this world . thanks thanks thanks thanks . will check the question after 10 minute.

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.