summaryrefslogtreecommitdiff
path: root/icu4j/main/classes
diff options
context:
space:
mode:
authorJoachim Sauer <jsauer@google.com>2016-05-26 11:46:57 +0100
committerFredrik Roubert <roubert@google.com>2017-07-06 14:59:41 +0200
commit8d6b8d1c4add0ec58abc983c372ca53361bb77ae (patch)
treea0453fc160e7355bdd5e2e2250b8d8039348120c /icu4j/main/classes
parent7d09282b14753890f8b1fe594552c7877ff83f6a (diff)
downloadicu-8d6b8d1c4add0ec58abc983c372ca53361bb77ae.tar.gz
Android patch: Add a method to clear the cached default timezone.
Adds clearCacheDefault() method that clears the cached timezone. This method is hidden from the public API and will only be used by java.util.TimeZone to ensure that ICU has the same view of what the default timezone is as java.util.TimeZone. This (together with the corresponding change in libcore) means that the calling android.icu.util.TimeZone.setDefault() with a value foo does not guarantee that the ICU default timezone after the call is equal to foo since the value will be conferted to a JDK-equivalent in ICU TimeZone.setDefault() and back to a ICU equivalent in ICU TimeZone.getDefault(). Both of these processes are potentially lossy. Background: When java.util.TimeZone.setDefault() is called (either by client code or from ActivityThread.updateTimeZone due to ACTION_TIMEZONE_CHANGED) we need to notify android.icu.util.TimeZone of this change, as it keeps a cached android.icu.util.TimeZone object to represent that default value. android.icu.util.TimeZone.setTimeZone would be the obvious candidate here. Unfortunately that method was hidden to have a single consistent way to set the timezone and tries to do some extra work that is undesireable on Android. This change was introduced in Android by this patch: https://android.googlesource.com/platform/external/icu/+/9e63f9d (cherry picked from commit 569adadff46a73f68362eef83ec20285478b46da) Change-Id: Ib3aa7953e37436bbf53626d458b74da11d309f6f
Diffstat (limited to 'icu4j/main/classes')
-rw-r--r--icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java
index c10d3ffd8..a16721c11 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/util/TimeZone.java
@@ -951,6 +951,18 @@ abstract public class TimeZone implements Serializable, Cloneable, Freezable<Tim
return tmpDefaultZone.cloneAsThawed();
}
+ // Android patch (http://b/28949992) start.
+ // ICU TimeZone.setDefault() not supported on Android.
+ /**
+ * Clears the cached default time zone.
+ * This causes {@link #getDefault()} to re-request the default time zone
+ * from {@link java.util.TimeZone}.
+ */
+ public static synchronized void clearCachedDefault() {
+ defaultZone = null;
+ }
+ // Android patch (http://b/28949992) end.
+
/**
* Sets the <code>TimeZone</code> that is
* returned by the <code>getDefault</code> method. If <code>zone</code>