Commits

Anonymous committed 81faf89

Use SimpleDateFormat for time zone formatting.

There's no need to do time zone formatting manually.

Change-Id: Ibef222d11d04a327e9ef64ddc48322558028555d

Comments (0)

Files changed (2)

src/com/android/settings/DateTimeSettings.java

 import android.widget.DatePicker;
 import android.widget.TimePicker;
 
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.TimeZone;
         }
     }
 
-    /*  Helper routines to format timezone */
-
-    /* package */ static String getTimeZoneText(TimeZone tz) {
-        // Similar to new SimpleDateFormat("'GMT'Z, zzzz").format(new Date()), but
-        // we want "GMT-03:00" rather than "GMT-0300".
-        Date now = new Date();
-        return formatOffset(new StringBuilder(), tz, now).
-            append(", ").
-            append(tz.getDisplayName(tz.inDaylightTime(now), TimeZone.LONG)).toString();
-    }
-
-    private static StringBuilder formatOffset(StringBuilder sb, TimeZone tz, Date d) {
-        int off = tz.getOffset(d.getTime()) / 1000 / 60;
-
-        sb.append("GMT");
-        if (off < 0) {
-            sb.append('-');
-            off = -off;
-        } else {
-            sb.append('+');
-        }
-
-        int hours = off / 60;
-        int minutes = off % 60;
-
-        sb.append((char) ('0' + hours / 10));
-        sb.append((char) ('0' + hours % 10));
-
-        sb.append(':');
-
-        sb.append((char) ('0' + minutes / 10));
-        sb.append((char) ('0' + minutes % 10));
-
-        return sb;
+    private static String getTimeZoneText(TimeZone tz) {
+        SimpleDateFormat sdf = new SimpleDateFormat("ZZZZ, zzzz");
+        sdf.setTimeZone(tz);
+        return sdf.format(new Date());
     }
 
     private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {

src/com/android/settings/DateTimeSettingsSetupWizard.java

         mSelectedTimeZone = tz;
         mTimeZoneButton = (Button)findViewById(R.id.time_zone_button);
         mTimeZoneButton.setText(tz.getDisplayName());
-        // mTimeZoneButton.setText(DateTimeSettings.getTimeZoneText(tz));
         mTimeZoneButton.setOnClickListener(this);
 
         final boolean autoDateTimeEnabled;
             if (mTimeZoneButton != null) {
                 mTimeZoneButton.setText(tz.getDisplayName());
             }
-            // mTimeZoneButton.setText(DateTimeSettings.getTimeZoneText(tz));
             mDatePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
                     now.get(Calendar.DAY_OF_MONTH));
             mTimePicker.setCurrentHour(now.get(Calendar.HOUR_OF_DAY));
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.