diff options
-rw-r--r-- | luni/src/main/java/libcore/icu/ICU.java | 3 | ||||
-rw-r--r-- | luni/src/main/native/libcore_icu_ICU.cpp | 11 | ||||
-rw-r--r-- | luni/src/test/java/libcore/icu/ICUTest.java | 8 |
3 files changed, 22 insertions, 0 deletions
diff --git a/luni/src/main/java/libcore/icu/ICU.java b/luni/src/main/java/libcore/icu/ICU.java index 0ef3f93..42def54 100644 --- a/luni/src/main/java/libcore/icu/ICU.java +++ b/luni/src/main/java/libcore/icu/ICU.java @@ -457,4 +457,7 @@ public final class ICU { * Returns a locale name, not a BCP-47 language tag. e.g. en_US not en-US. */ public static native String getDefaultLocale(); + + /** Returns the TZData version as reported by ICU4C. */ + public static native String getTZDataVersion(); } diff --git a/luni/src/main/native/libcore_icu_ICU.cpp b/luni/src/main/native/libcore_icu_ICU.cpp index ee4fe6e..ff76a16 100644 --- a/luni/src/main/native/libcore_icu_ICU.cpp +++ b/luni/src/main/native/libcore_icu_ICU.cpp @@ -38,6 +38,7 @@ #include "unicode/locid.h" #include "unicode/numfmt.h" #include "unicode/strenum.h" +#include "unicode/timezone.h" #include "unicode/ubrk.h" #include "unicode/ucal.h" #include "unicode/uclean.h" @@ -726,6 +727,15 @@ static jstring ICU_getUnicodeVersion(JNIEnv* env, jclass) { return versionString(env, unicodeVersion); } +static jstring ICU_getTZDataVersion(JNIEnv* env, jclass) { + UErrorCode status = U_ZERO_ERROR; + const char* version = icu::TimeZone::getTZDataVersion(status); + if (maybeThrowIcuException(env, "icu::TimeZone::getTZDataVersion", status)) { + return NULL; + } + return env->NewStringUTF(version); +} + static jobject ICU_getAvailableCurrencyCodes(JNIEnv* env, jclass) { UErrorCode status = U_ZERO_ERROR; icu::UStringEnumeration e(ucurr_openISOCurrencies(UCURR_COMMON|UCURR_NON_DEPRECATED, &status)); @@ -798,6 +808,7 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(ICU, getISOLanguagesNative, "()[Ljava/lang/String;"), NATIVE_METHOD(ICU, getIcuVersion, "()Ljava/lang/String;"), NATIVE_METHOD(ICU, getScript, "(Ljava/lang/String;)Ljava/lang/String;"), + NATIVE_METHOD(ICU, getTZDataVersion, "()Ljava/lang/String;"), NATIVE_METHOD(ICU, getUnicodeVersion, "()Ljava/lang/String;"), NATIVE_METHOD(ICU, initLocaleDataNative, "(Ljava/lang/String;Llibcore/icu/LocaleData;)Z"), NATIVE_METHOD(ICU, setDefaultLocale, "(Ljava/lang/String;)V"), diff --git a/luni/src/test/java/libcore/icu/ICUTest.java b/luni/src/test/java/libcore/icu/ICUTest.java index 46f4ebe..99679a7 100644 --- a/luni/src/test/java/libcore/icu/ICUTest.java +++ b/luni/src/test/java/libcore/icu/ICUTest.java @@ -20,6 +20,7 @@ import java.text.BreakIterator; import java.text.Collator; import java.util.Arrays; import java.util.Locale; +import libcore.util.ZoneInfoDB; public class ICUTest extends junit.framework.TestCase { public void test_getISOLanguages() throws Exception { @@ -253,4 +254,11 @@ public class ICUTest extends junit.framework.TestCase { ICU.setDefaultLocale(initialDefaultLocale); } } + + /** Confirms that ICU agrees with the rest of libcore about the version of the TZ data in use. */ + public void testTimeZoneDataVersion() { + String icu4cTzVersion = ICU.getTZDataVersion(); + String zoneInfoTzVersion = ZoneInfoDB.getInstance().getVersion(); + assertEquals(icu4cTzVersion, zoneInfoTzVersion); + } } |