OSDN Git Service

Change dummy calendar setting during locale change
authorKenny Root <kroot@google.com>
Mon, 13 Jun 2011 02:44:14 +0000 (19:44 -0700)
committerKenny Root <kroot@google.com>
Mon, 13 Jun 2011 03:54:53 +0000 (20:54 -0700)
If the timezone changed too far, the example date would be "1/1/yyyy+1"
instead of "12/31/yyyy"

Move the setting of the Calendar time to where the string is calculated
to make sure we have the most up-to-date Locale.

Bug: 4596841
Change-Id: I67a253a65b1ea03ee717945c5df819beb8515662

src/com/android/settings/DateTimeSettings.java

index d2c5973..31e6a33 100644 (file)
@@ -88,7 +88,6 @@ public class DateTimeSettings extends SettingsPreferenceFragment
         boolean isFirstRun = intent.getBooleanExtra(EXTRA_IS_FIRST_RUN, false);
 
         mDummyDate = Calendar.getInstance();
-        mDummyDate.set(mDummyDate.get(Calendar.YEAR), 11, 31, 13, 0, 0);
 
         mAutoTimePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME);
         mAutoTimePref.setChecked(autoTimeEnabled);
@@ -171,6 +170,8 @@ public class DateTimeSettings extends SettingsPreferenceFragment
     public void updateTimeAndDateDisplay(Context context) {
         java.text.DateFormat shortDateFormat = DateFormat.getDateFormat(context);
         final Calendar now = Calendar.getInstance();
+        mDummyDate.setTimeZone(now.getTimeZone());
+        mDummyDate.set(now.get(Calendar.YEAR), 11, 31, 13, 0, 0);
         Date dummyDate = mDummyDate.getTime();
         mTimePref.setSummary(DateFormat.getTimeFormat(getActivity()).format(now.getTime()));
         mTimeZone.setSummary(getTimeZoneText(now.getTimeZone()));