Merge "Avoid a @Nullable Boolean"
This commit is contained in:
@@ -18,7 +18,6 @@ package android.timezone;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.icu.util.TimeZone;
|
import android.icu.util.TimeZone;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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
|
* Returns a time zone for the country, if there is one, that matches the supplied properties.
|
||||||
* there are multiple matches and the {@code bias} is one of them then it is returned, otherwise
|
* If there are multiple matches and the {@code bias} is one of them then it is returned,
|
||||||
* an arbitrary match is returned based on the {@link #getEffectiveTimeZoneMappingsAt(long)}
|
* otherwise an arbitrary match is returned based on the {@link
|
||||||
* ordering.
|
* #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 totalOffsetMillis the offset from UTC at {@code whenMillis}
|
||||||
* @param isDst the Daylight Savings Time state at {@code whenMillis}. {@code true} means DST,
|
* @param isDst the Daylight Savings Time state at {@code whenMillis}. {@code true} means DST,
|
||||||
* {@code false} means not DST, {@code null} means unknown
|
* {@code false} means not DST
|
||||||
* @param dstOffsetMillis the part of {@code totalOffsetMillis} contributed by DST, only used if
|
* @return an {@link OffsetResult} with information about a matching zone, or {@code null} if
|
||||||
* {@code isDst} is {@code true}. The value can be {@code null} if the DST offset is
|
* there is no match
|
||||||
* unknown
|
|
||||||
* @param whenMillis the UTC time to match against
|
|
||||||
* @param bias the time zone to prefer, can be {@code null}
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public OffsetResult lookupByOffsetWithBias(int totalOffsetMillis, @Nullable Boolean isDst,
|
public OffsetResult lookupByOffsetWithBias(long whenMillis, @Nullable TimeZone bias,
|
||||||
@SuppressLint("AutoBoxing") @Nullable Integer dstOffsetMillis, long whenMillis,
|
int totalOffsetMillis, boolean isDst) {
|
||||||
@Nullable TimeZone bias) {
|
|
||||||
libcore.timezone.CountryTimeZones.OffsetResult delegateOffsetResult =
|
libcore.timezone.CountryTimeZones.OffsetResult delegateOffsetResult =
|
||||||
mDelegate.lookupByOffsetWithBias(
|
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 :
|
return delegateOffsetResult == null ? null :
|
||||||
new OffsetResult(
|
new OffsetResult(
|
||||||
delegateOffsetResult.getTimeZone(), delegateOffsetResult.isOnlyMatch());
|
delegateOffsetResult.getTimeZone(), delegateOffsetResult.isOnlyMatch());
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class TimeUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
CountryTimeZones.OffsetResult offsetResult = countryTimeZones.lookupByOffsetWithBias(
|
CountryTimeZones.OffsetResult offsetResult = countryTimeZones.lookupByOffsetWithBias(
|
||||||
offsetMillis, isDst, null /* dstOffsetMillis */, whenMillis, bias);
|
whenMillis, bias, offsetMillis, isDst);
|
||||||
return offsetResult != null ? offsetResult.getTimeZone() : null;
|
return offsetResult != null ? offsetResult.getTimeZone() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user