0

I need to change this format to Date

Fri Oct 28 05:47:54 SGT 2011

I not sure the SGT how to set?

2 Answers 2

6

You can find all patterns in the SimpleDateFormat javadoc. SGT is a general time zone and it's listed as z. So, the pattern should look like:

EEE MMM dd HH:mm:ss z yyyy

The month names seems to be English, so this should do in combination with Locale.ENGLISH:

SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
Date date = sdf.parse(string);
// ...

Interesting enough, that's also basically the default pattern of the Date#toString() method (which you would see when you're doing a System.out.println(date), for example).

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

Comments

0

Take a look at the DateFormat class, specifically the parse method.

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.