summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2015-04-30 16:20:32 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-30 16:20:33 +0000
commita9c0a52e64ceed9de66eed2f2eb568cd4e95d3ff (patch)
treea61284aa7f4c50c62d13062105782c17243eb093
parent713ceebccc66477e149dec18cad0baedec7e6741 (diff)
parent8ac094531caac4c2b1126f8630211603813c97fb (diff)
downloadlibcore-a9c0a52e64ceed9de66eed2f2eb568cd4e95d3ff.zip
libcore-a9c0a52e64ceed9de66eed2f2eb568cd4e95d3ff.tar.gz
libcore-a9c0a52e64ceed9de66eed2f2eb568cd4e95d3ff.tar.bz2
Merge "Add a ZoneInfoDB.hasTimeZone API."
-rw-r--r--luni/src/main/java/libcore/util/ZoneInfoDB.java4
-rw-r--r--luni/src/test/java/libcore/util/ZoneInfoDBTest.java7
2 files changed, 11 insertions, 0 deletions
diff --git a/luni/src/main/java/libcore/util/ZoneInfoDB.java b/luni/src/main/java/libcore/util/ZoneInfoDB.java
index b8e1dad..fd8570c 100644
--- a/luni/src/main/java/libcore/util/ZoneInfoDB.java
+++ b/luni/src/main/java/libcore/util/ZoneInfoDB.java
@@ -249,6 +249,10 @@ public final class ZoneInfoDB {
// The object from the cache is cloned because TimeZone / ZoneInfo are mutable.
return zoneInfo == null ? null : (ZoneInfo) zoneInfo.clone();
}
+
+ public boolean hasTimeZone(String id) throws IOException {
+ return cache.get(id) != null;
+ }
}
private ZoneInfoDB() {
diff --git a/luni/src/test/java/libcore/util/ZoneInfoDBTest.java b/luni/src/test/java/libcore/util/ZoneInfoDBTest.java
index 9875647..a90bb8e 100644
--- a/luni/src/test/java/libcore/util/ZoneInfoDBTest.java
+++ b/luni/src/test/java/libcore/util/ZoneInfoDBTest.java
@@ -98,6 +98,13 @@ public class ZoneInfoDBTest extends junit.framework.TestCase {
public void testMakeTimeZone_notFound() throws Exception {
ZoneInfoDB.TzData data = new ZoneInfoDB.TzData(TZDATA_IN_ROOT);
assertNull(data.makeTimeZone("THIS_TZ_DOES_NOT_EXIST"));
+ assertFalse(data.hasTimeZone("THIS_TZ_DOES_NOT_EXIST"));
+ }
+
+ public void testMakeTimeZone_found() throws Exception {
+ ZoneInfoDB.TzData data = new ZoneInfoDB.TzData(TZDATA_IN_ROOT);
+ assertNotNull(data.makeTimeZone("Europe/London"));
+ assertTrue(data.hasTimeZone("Europe/London"));
}
private static String makeCorruptFile() throws Exception {