is SimpleDateFormat diffrent in Java & Android? -


i use below code in java , works perfect !

simpledateformat format = new simpledateformat("e, dd mmm yyyy hh:mm:ss z"); date date = format.parse("sun, 11 may 2014 23:11:51 +0430"); 

but in android got exception !

java.text.parseexception: unparseable date: "sun, 11 may 2014 23:11:51 +0430" (at offset 0) 

what's wrong ?!

the problem code execute correctly if default locale english, otherwise throw exception. can solve adding correct locale.

//locale locale = new locale("en-us");   locale locale = locale.us;   simpledateformat format = new simpledateformat("e, dd mmm yyyy hh:mm:ss z", locale); date date = format.parse("sun, 11 may 2014 23:11:51 +0430"); 

probably android device has different language setting. consider using constant locale rc stated in comment, in case wouldn't need variable, use constant directly in constructor.


Comments

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -