1

I'm trying to parse string representation of date. It looks like 20120306 14:21:35 MSK +0400. I'm using a SimpleDateFormat to parse it into a Date and a pattern string according to http://developer.android.com/reference/java/text/SimpleDateFormat.html

DATE_PATTERN = "yyyyMMdd kk:mm:ss z Z";
SimpleDateFormat dateFormat=new SimpleDateFormat(DATE_PATTERN);
Date date=dateFormat.parse(dateString);

I've try different z/Z combinations but have no result, except ParseException of course :)

Probably i'm doing something wrong, but what?

I'll be very glad for any help! Thanks in advance!

1 Answer 1

2

It doesn't recognise "MSK" as a valid time zone so try this instead:

String DATE_PATTERN = "yyyyMMdd kk:mm:ss z Z";
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
Date date = dateFormat.parse(dateString.replaceAll("MSK", "GMT"));
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.