0

I have a string with format "Mon Dec 03 00:00:00 IST 2012". I want to convert this string into Date. Any formats will do.

1
  • Thank You everyone for your quick response. Commented Dec 3, 2012 at 8:48

5 Answers 5

3

can try:

SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
    try {
        Date date = sdf.parse("Mon Dec 03 00:00:00 IST 2012");
    } catch (ParseException e) {
        e.printStackTrace();
    }
Sign up to request clarification or add additional context in comments.

Comments

2

You can use parse() method of SimpleDateFormat class. Read the API documentation here.

Comments

2

date format of your string-represented date is:

DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");

1 Comment

It should be EEE instead of E
1

Use a SimpleDateFormatter. You can find details about them here:

SimpleDateFormat

Comments

1

DateFormat dateFormat = new SimpleDateFormat("E MMM dd HH:mm:ss zzz yyyy");

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.