am 5f6e4339
: Merge "Use SimpleDateFormat for time zone formatting."
* commit '5f6e43394dd89432b241f32cd2c96d87c3ad5040': Use SimpleDateFormat for time zone formatting.
This commit is contained in:
@@ -39,6 +39,7 @@ import android.text.format.DateFormat;
|
|||||||
import android.widget.DatePicker;
|
import android.widget.DatePicker;
|
||||||
import android.widget.TimePicker;
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
@@ -372,40 +373,10 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper routines to format timezone */
|
private static String getTimeZoneText(TimeZone tz) {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("ZZZZ, zzzz");
|
||||||
/* package */ static String getTimeZoneText(TimeZone tz) {
|
sdf.setTimeZone(tz);
|
||||||
// Similar to new SimpleDateFormat("'GMT'Z, zzzz").format(new Date()), but
|
return sdf.format(new Date());
|
||||||
// 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 BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
|
||||||
|
@@ -121,7 +121,6 @@ public class DateTimeSettingsSetupWizard extends Activity
|
|||||||
mSelectedTimeZone = tz;
|
mSelectedTimeZone = tz;
|
||||||
mTimeZoneButton = (Button)findViewById(R.id.time_zone_button);
|
mTimeZoneButton = (Button)findViewById(R.id.time_zone_button);
|
||||||
mTimeZoneButton.setText(tz.getDisplayName());
|
mTimeZoneButton.setText(tz.getDisplayName());
|
||||||
// mTimeZoneButton.setText(DateTimeSettings.getTimeZoneText(tz));
|
|
||||||
mTimeZoneButton.setOnClickListener(this);
|
mTimeZoneButton.setOnClickListener(this);
|
||||||
|
|
||||||
final boolean autoDateTimeEnabled;
|
final boolean autoDateTimeEnabled;
|
||||||
@@ -245,7 +244,6 @@ public class DateTimeSettingsSetupWizard extends Activity
|
|||||||
if (mTimeZoneButton != null) {
|
if (mTimeZoneButton != null) {
|
||||||
mTimeZoneButton.setText(tz.getDisplayName());
|
mTimeZoneButton.setText(tz.getDisplayName());
|
||||||
}
|
}
|
||||||
// mTimeZoneButton.setText(DateTimeSettings.getTimeZoneText(tz));
|
|
||||||
mDatePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
|
mDatePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
|
||||||
now.get(Calendar.DAY_OF_MONTH));
|
now.get(Calendar.DAY_OF_MONTH));
|
||||||
mTimePicker.setCurrentHour(now.get(Calendar.HOUR_OF_DAY));
|
mTimePicker.setCurrentHour(now.get(Calendar.HOUR_OF_DAY));
|
||||||
|
Reference in New Issue
Block a user