summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2019-09-10 04:17:20 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-09-10 04:17:20 -0700
commite5c466d3f58f26be4e53f84cc5fd329b520de2b9 (patch)
treec9800066435f72174551406c19a12cc6fdcd519c /core/java/android
parentca61da8141d0bfe4d10e46c825d6a63a35c12aa6 (diff)
parenta7d5a3220a547c12861fd4d39db6a566d0da5020 (diff)
Merge "Simplify APIs exposed for time zone lookups" am: 07dcc4bc0f
am: a7d5a3220a Change-Id: I058dbe387bbebe61eb03507e64285fa27f0b7108
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/util/TimeUtils.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/core/java/android/util/TimeUtils.java b/core/java/android/util/TimeUtils.java
index f8b38e9d215d..07cecd38620d 100644
--- a/core/java/android/util/TimeUtils.java
+++ b/core/java/android/util/TimeUtils.java
@@ -62,9 +62,9 @@ public class TimeUtils {
}
/**
- * Tries to return a frozen ICU time zone that would have had the specified offset
- * and DST value at the specified moment in the specified country.
- * Returns null if no suitable zone could be found.
+ * Returns a frozen ICU time zone that has / would have had the specified offset and DST value
+ * at the specified moment in the specified country. Returns null if no suitable zone could be
+ * found.
*/
private static android.icu.util.TimeZone getIcuTimeZone(
int offset, boolean dst, long when, String country) {
@@ -73,8 +73,15 @@ public class TimeUtils {
}
android.icu.util.TimeZone bias = android.icu.util.TimeZone.getDefault();
- return TimeZoneFinder.getInstance()
- .lookupTimeZoneByCountryAndOffset(country, offset, dst, when, bias);
+ CountryTimeZones countryTimeZones =
+ TimeZoneFinder.getInstance().lookupCountryTimeZones(country);
+ if (countryTimeZones == null) {
+ return null;
+ }
+
+ CountryTimeZones.OffsetResult offsetResult =
+ countryTimeZones.lookupByOffsetWithBias(offset, dst, when, bias);
+ return offsetResult != null ? offsetResult.mTimeZone : null;
}
/**