diff options
| author | 2019-08-20 11:01:57 +0000 | |
|---|---|---|
| committer | 2019-08-20 11:01:57 +0000 | |
| commit | f7a60ec323bdbc8e99f7b43b87997062125a9ab5 (patch) | |
| tree | 1f378fdab22373fe2af3eefc47820bebe9dfd477 | |
| parent | 37b91f5b951f68cc4b8ec825ab4a131b74e298dd (diff) | |
| parent | 400efa36ef8666ad8341c36679a4f2cb9fd00f9f (diff) | |
Merge "Simplify APIs exposed for time zone lookups"
| -rw-r--r-- | core/java/android/util/TimeUtils.java | 17 |
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; } /** |