summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Neil Fuller <nfuller@google.com> 2019-09-10 04:24:22 -0700
committer android-build-merger <android-build-merger@google.com> 2019-09-10 04:24:22 -0700
commit3cf1c83e5d6312386115dc6d4a593b60f89a89e2 (patch)
tree3179ede7a47f6b06dcaee961dd5ad7035285b044
parent383ec7f4846aeaccfaf788f600e4d71305df7593 (diff)
parente5c466d3f58f26be4e53f84cc5fd329b520de2b9 (diff)
Merge "Simplify APIs exposed for time zone lookups" am: 07dcc4bc0f am: a7d5a3220a
am: e5c466d3f5 Change-Id: I8f9c268ac2cf791959a74cd4413b4e1d03c67c56
-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;
}
/**