I trying to parse following 11 Ноя 1980 г.
string into date. This string is in russian formatting. I am using this code snippet to parse this.
Locale locale = new Locale("ru", "RU");
System.out.println(locale.toString());
DateFormat full = DateFormat.getDateInstance(DateFormat.LONG, locale);
try {
Date date = full.parse("11 Ноя 1980 г.");
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
}
While running this code as an normal java program outputs in parsed date object, but running this on android gives following exception.
11-20 03:52:45.545 11241-11241/com.marcow.birthdaylist W/System.err: java.text.ParseException: Unparseable date: "11 Ноя 1980 г." (at offset 3)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at java.text.DateFormat.parse(DateFormat.java:579)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at com.marcow.birthdaylist.TestActivity.onCreate(TestActivity.java:44)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at android.app.Activity.performCreate(Activity.java:6237)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at android.app.ActivityThread.-wrap11(ActivityThread.java)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at android.os.Looper.loop(Looper.java:148)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at java.lang.reflect.Method.invoke(Native Method)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-20 03:52:45.546 11241-11241/com.marcow.birthdaylist W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I don't understand why it's behaving differently on java and android.