summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-06 09:24:58 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-06 09:24:58 +0000
commit3e04f5af272c7022b51896e4d088fe8917cece7a (patch)
tree6e0a7ff8d47779db3d913d373219a6fb7228d830 /core/java
parentd73366e3970bd429765423ccce71d3ea12de1579 (diff)
parent0db1f949da61b6b705f9fe99bbc2178416467897 (diff)
Merge "Avoid a @Nullable Boolean" am: 81a42af40d am: fd9c242128 am: 0db1f949da
Change-Id: Iae09c0c6e0d0b8cc9018b811c658d7d73e8a729b
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/timezone/CountryTimeZones.java49
-rw-r--r--core/java/android/util/TimeUtils.java2
2 files changed, 35 insertions, 16 deletions
diff --git a/core/java/android/timezone/CountryTimeZones.java b/core/java/android/timezone/CountryTimeZones.java
index ab2c4fc1bf23..ee3a8a79d5d7 100644
--- a/core/java/android/timezone/CountryTimeZones.java
+++ b/core/java/android/timezone/CountryTimeZones.java
@@ -18,7 +18,6 @@ package android.timezone;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.SuppressLint;
import android.icu.util.TimeZone;
import java.util.ArrayList;
@@ -206,27 +205,47 @@ public final class CountryTimeZones {
}
/**
- * Returns a time zone for the country, if there is one, that matches the desired properties. If
- * there are multiple matches and the {@code bias} is one of them then it is returned, otherwise
- * an arbitrary match is returned based on the {@link #getEffectiveTimeZoneMappingsAt(long)}
- * ordering.
+ * Returns a time zone for the country, if there is one, that matches the supplied properties.
+ * If there are multiple matches and the {@code bias} is one of them then it is returned,
+ * otherwise an arbitrary match is returned based on the {@link
+ * #getEffectiveTimeZoneMappingsAt(long)} ordering.
*
+ * @param whenMillis the UTC time to match against
+ * @param bias the time zone to prefer, can be {@code null} to indicate there is no preference
* @param totalOffsetMillis the offset from UTC at {@code whenMillis}
* @param isDst the Daylight Savings Time state at {@code whenMillis}. {@code true} means DST,
- * {@code false} means not DST, {@code null} means unknown
- * @param dstOffsetMillis the part of {@code totalOffsetMillis} contributed by DST, only used if
- * {@code isDst} is {@code true}. The value can be {@code null} if the DST offset is
- * unknown
- * @param whenMillis the UTC time to match against
- * @param bias the time zone to prefer, can be {@code null}
+ * {@code false} means not DST
+ * @return an {@link OffsetResult} with information about a matching zone, or {@code null} if
+ * there is no match
*/
@Nullable
- public OffsetResult lookupByOffsetWithBias(int totalOffsetMillis, @Nullable Boolean isDst,
- @SuppressLint("AutoBoxing") @Nullable Integer dstOffsetMillis, long whenMillis,
- @Nullable TimeZone bias) {
+ public OffsetResult lookupByOffsetWithBias(long whenMillis, @Nullable TimeZone bias,
+ int totalOffsetMillis, boolean isDst) {
libcore.timezone.CountryTimeZones.OffsetResult delegateOffsetResult =
mDelegate.lookupByOffsetWithBias(
- totalOffsetMillis, isDst, dstOffsetMillis, whenMillis, bias);
+ whenMillis, bias, totalOffsetMillis, isDst);
+ return delegateOffsetResult == null ? null :
+ new OffsetResult(
+ delegateOffsetResult.getTimeZone(), delegateOffsetResult.isOnlyMatch());
+ }
+
+ /**
+ * Returns a time zone for the country, if there is one, that matches the supplied properties.
+ * If there are multiple matches and the {@code bias} is one of them then it is returned,
+ * otherwise an arbitrary match is returned based on the {@link
+ * #getEffectiveTimeZoneMappingsAt(long)} ordering.
+ *
+ * @param whenMillis the UTC time to match against
+ * @param bias the time zone to prefer, can be {@code null} to indicate there is no preference
+ * @param totalOffsetMillis the offset from UTC at {@code whenMillis}
+ * @return an {@link OffsetResult} with information about a matching zone, or {@code null} if
+ * there is no match
+ */
+ @Nullable
+ public OffsetResult lookupByOffsetWithBias(long whenMillis, @Nullable TimeZone bias,
+ int totalOffsetMillis) {
+ libcore.timezone.CountryTimeZones.OffsetResult delegateOffsetResult =
+ mDelegate.lookupByOffsetWithBias(whenMillis, bias, totalOffsetMillis);
return delegateOffsetResult == null ? null :
new OffsetResult(
delegateOffsetResult.getTimeZone(), delegateOffsetResult.isOnlyMatch());
diff --git a/core/java/android/util/TimeUtils.java b/core/java/android/util/TimeUtils.java
index 36f4e5361ea6..4b3afbaada64 100644
--- a/core/java/android/util/TimeUtils.java
+++ b/core/java/android/util/TimeUtils.java
@@ -80,7 +80,7 @@ public class TimeUtils {
return null;
}
CountryTimeZones.OffsetResult offsetResult = countryTimeZones.lookupByOffsetWithBias(
- offsetMillis, isDst, null /* dstOffsetMillis */, whenMillis, bias);
+ whenMillis, bias, offsetMillis, isDst);
return offsetResult != null ? offsetResult.getTimeZone() : null;
}