Skip to content Skip to sidebar Skip to footer

App Crashes When The User Changes The Device Language

I have an App that store some objects that contain a String date on a file, this String for some operations need to be parsed as GregorianCalendar. Now I have found this issue: whe

Solution 1:

In this line

DateFormatformat=newSimpleDateFormat(formatPattern);

you use the default locale, and the default locale is associated to current language of device, if you change the Language the default locale doesn't match the locale used to store the String causing the error.

To avoid this issue you have to store the Locale used to get the String date and pass it to the DateFormat

DateFormatformat=newSimpleDateFormat(formatPattern, localeOfTheDateString);

or store the date directly as GregorianCalendar objects

Post a Comment for "App Crashes When The User Changes The Device Language"