summaryrefslogtreecommitdiffstats
path: root/luni/src/main/native/TimeZones.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/native/TimeZones.cpp')
-rw-r--r--luni/src/main/native/TimeZones.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/luni/src/main/native/TimeZones.cpp b/luni/src/main/native/TimeZones.cpp
index bb6cee9..146f90b 100644
--- a/luni/src/main/native/TimeZones.cpp
+++ b/luni/src/main/native/TimeZones.cpp
@@ -62,8 +62,17 @@ static jobjectArray TimeZones_forCountryCode(JNIEnv* env, jclass, jstring countr
}
static jstring TimeZones_getDisplayNameImpl(JNIEnv* env, jclass, jstring javaZoneId, jboolean isDST, jint style, jstring localeId) {
+ // Get an ICU4C TimeZone* for the given id. Really, we want TimeZone::createSystemTimeZone,
+ // but that's not public. Instead, we have to check we got the time zone we wanted, rather
+ // than a clone of GMT. (http://b/3394198 asks for ICU to expose the more useful method.)
ScopedJavaUnicodeString zoneId(env, javaZoneId);
UniquePtr<TimeZone> zone(TimeZone::createTimeZone(zoneId.unicodeString()));
+ UnicodeString actualZoneId;
+ zone->getID(actualZoneId);
+ if (actualZoneId != zoneId.unicodeString()) {
+ return NULL;
+ }
+
Locale locale = getLocale(env, localeId);
// Try to get the display name of the TimeZone according to the Locale
UnicodeString displayName;