Replace @CorePlatformApi APIs usages in TimeZoneInfoPreferenceControllerTest
The time zone transitions can be obtained via the public API ZoneId.getRules() instead. Bug: 119751170 Test: atest SettingsRoboTests com.android.settings.datetime.timezone.TimeZoneInfoPreferenceControllerTest passes Change-Id: I2c7864580b2a36b725ee250253e97f6cc86d72a4
This commit is contained in:
@@ -151,7 +151,7 @@ public class TimeZoneInfo {
|
||||
public TimeZoneInfo format(TimeZone timeZone) {
|
||||
String canonicalZoneId = getCanonicalZoneId(timeZone);
|
||||
final TimeZoneNames timeZoneNames = mTimeZoneFormat.getTimeZoneNames();
|
||||
final java.util.TimeZone javaTimeZone = java.util.TimeZone.getTimeZone(canonicalZoneId);
|
||||
final java.util.TimeZone javaTimeZone = toJavaTimeZone(canonicalZoneId);
|
||||
final CharSequence gmtOffset = ZoneGetter.getGmtOffsetText(mTimeZoneFormat, mLocale,
|
||||
javaTimeZone, mNow);
|
||||
return new TimeZoneInfo.Builder(timeZone)
|
||||
@@ -165,15 +165,24 @@ public class TimeZoneInfo {
|
||||
.setGmtOffset(gmtOffset)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getCanonicalZoneId(TimeZone timeZone) {
|
||||
final String id = timeZone.getID();
|
||||
final String canonicalId = TimeZone.getCanonicalID(id);
|
||||
if (canonicalId != null) {
|
||||
return canonicalId;
|
||||
}
|
||||
return id;
|
||||
/* package-private */ java.util.TimeZone getJavaTimeZone() {
|
||||
String canonicalZoneId = getCanonicalZoneId(mTimeZone);
|
||||
return toJavaTimeZone(canonicalZoneId);
|
||||
}
|
||||
|
||||
private static java.util.TimeZone toJavaTimeZone(String canonicalZoneId) {
|
||||
return java.util.TimeZone.getTimeZone(canonicalZoneId);
|
||||
}
|
||||
|
||||
private static String getCanonicalZoneId(TimeZone timeZone) {
|
||||
final String id = timeZone.getID();
|
||||
final String canonicalId = TimeZone.getCanonicalID(id);
|
||||
if (canonicalId != null) {
|
||||
return canonicalId;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user