Simpledateformat parse issue
I'm parsing a date which is in format EEE, dd MMM yyyy HH:mm:ss Z
. One of the sample values is Thu, 02 Sep 2010 04:03:10 -0700
.
This is the parsing code:
SimpleDateFormat FORMATTER = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z");
Date date = FORMATTER.parse(dateString);
This works absolutely fine if Phone Language is English but it throws parserException when language is changed to "France" or "Italian". I have even tried this:
SimpleDateFormat FORMATTER = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.getDefault());
or for French locale more explicit:
SimpleDateFormat FORMATTER = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.French);
But no luck.....Can someone tell me what I am 开发者_如何学Pythondoing wrong?
Since "Thu" is English, you'll want to use Locale.ENGLISH
to parse it.
精彩评论