You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In TimePickerPreference.java a static SimpleDateFormat FORMAT is defined which saves the local time zone at creation time (line 49) for the entire application process lifetime.
This format is used to parse a time String into a Date object (receives the time zone from FORMAT, line 240) and then the result is assigned to a newly instantiated Calendar object (that has the current local time zone, line 277).
When the System's time zone changes between storing a time String into SharedPreferences and recovering it from SharedPreferences while the application process is still running, then the hours (and probably minutes) are shifted to the new System time zone.
It only happens under very special circumstances, for example if you have an AppWidget and therefore a permanently running process - but that is exactly my use case of your fabulous Preference.
Suggestion to solve the issue: instead of using a static fixed FORMAT have a static method
public static getFORMAT() { return new SimpleDateFormat(PATTERN, Locale.US); }
Then you'll always have a format residing in the current time zone as the Calendar objects do.
The text was updated successfully, but these errors were encountered:
In TimePickerPreference.java a static SimpleDateFormat FORMAT is defined which saves the local time zone at creation time (line 49) for the entire application process lifetime.
This format is used to parse a time String into a Date object (receives the time zone from FORMAT, line 240) and then the result is assigned to a newly instantiated Calendar object (that has the current local time zone, line 277).
When the System's time zone changes between storing a time String into SharedPreferences and recovering it from SharedPreferences while the application process is still running, then the hours (and probably minutes) are shifted to the new System time zone.
It only happens under very special circumstances, for example if you have an AppWidget and therefore a permanently running process - but that is exactly my use case of your fabulous Preference.
Suggestion to solve the issue: instead of using a static fixed FORMAT have a static method
public static getFORMAT() { return new SimpleDateFormat(PATTERN, Locale.US); }
Then you'll always have a format residing in the current time zone as the Calendar objects do.
The text was updated successfully, but these errors were encountered: