0

I am trying to convert the following json string: "Mon Apr 04 00:00:00 CEST 2016" to a new date object by a simpleDateFormat. But i dont see why it wont work hope some one can help me.

String date = "Mon Apr 04 00:00:00 CEST 2016";

I get the following error:

(java.text.ParseException) java.text.ParseException: Unparseable date: "Mon Apr 04 00:00:00 CEST 2016"

public Date parseDate(String date) 
{ 
    try 
    {
        SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
        Date returnDate = formatter.parse(date);
        return returnDate;
    }
    catch (ParseException e) 
    {
            e.printStackTrace();
            return null;
    }
}
1
  • Works fine for me.Just tried this out Commented Apr 5, 2016 at 16:51

2 Answers 2

2

you need to parse with the locale:

SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
Sign up to request clarification or add additional context in comments.

Comments

0

"EEE MMM ddHH:mm:ss z yyyy"

looks you forgot to put the space after dd:

"EEE MMM dd HH:mm:ss z yyyy"

1 Comment

Sorry that was a copy paste mistake but it still not fix the problem i have

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.