Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77f97af8 authored by Victor Chang's avatar Victor Chang
Browse files

Fix incorrect GMT offset in display

- android.icu.impl.TimeZoneAdapter doesn't fully implement
java.util.TimeZone, e.g. does not override getOffset(long date).
TimeZoneAdapter isn't a public API in ICU/Android. It shouldn't be
used in the first place

Bug: 77223510
Test: m RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.datetime.timezone
Change-Id: Ic0d7794326948796dcc5cc0b268ef634a74803c4
parent 65f09f30
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ public class TimeZoneInfo {
        public TimeZoneInfo format(TimeZone timeZone) {
            final String id = timeZone.getID();
            final TimeZoneNames timeZoneNames = mTimeZoneFormat.getTimeZoneNames();
            final java.util.TimeZone javaTimeZone = android.icu.impl.TimeZoneAdapter.wrap(timeZone);
            final java.util.TimeZone javaTimeZone = java.util.TimeZone.getTimeZone(id);
            final CharSequence gmtOffset = ZoneGetter.getGmtOffsetText(mTimeZoneFormat, mLocale,
                javaTimeZone, mNow);
            return new TimeZoneInfo.Builder(timeZone)
+9 −0
Original line number Diff line number Diff line
@@ -43,4 +43,13 @@ public class TimeZoneInfoTest {
        assertThat(timeZoneInfo.getStandardName()).isEqualTo("Pacific Standard Time");
        assertThat(timeZoneInfo.getDaylightName()).isEqualTo("Pacific Daylight Time");
    }

    @Test
    public void getGmtOffset_zoneLordHowe_correctGmtOffset() {
        Date date = new Date(1514764800000L); // 00:00 1/1/2018 GMT
        Formatter formatter = new Formatter(Locale.US, date);

        TimeZoneInfo timeZoneInfo = formatter.format("Australia/Lord_Howe");
        assertThat(timeZoneInfo.getGmtOffset().toString()).isEqualTo("GMT+11:00");
    }
}