diff --git a/icu4j/build.xml b/icu4j/build.xml
index c9857d2f67e..739c74d2187 100644
--- a/icu4j/build.xml
+++ b/icu4j/build.xml
@@ -85,6 +85,8 @@
+
+
@@ -439,10 +441,26 @@
+
+
+
+
+
+
+
+
+
+
-
@@ -652,11 +669,10 @@
-
+
-
diff --git a/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java b/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java
index 73647e717d6..cdb9e51aaaa 100755
--- a/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java
+++ b/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java
@@ -69,6 +69,7 @@ public class TestFmwk extends AbstractTestLog {
}
String msg = ex.getMessage();
+ System.err.println("TF handleException msg: " + msg);
if (ex instanceof MissingResourceException || ex instanceof NoClassDefFoundError) {
if (params.warnings || params.nodata) {
warnln(msg);
@@ -989,9 +990,9 @@ public class TestFmwk extends AbstractTestLog {
public State stack;
- private StringBuffer errorSummary;
+ public StringBuffer errorSummary;
- private PrintWriter log;
+ public PrintWriter log;
public int indentLevel;
private boolean needLineFeed;
private boolean suppressIndent;
diff --git a/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java b/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java
index ef761d639f9..8d384249ff6 100755
--- a/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java
+++ b/icu4j/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java
@@ -17,6 +17,7 @@ package com.ibm.icu.dev.test.timezone;
import com.ibm.icu.dev.test.*;
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.util.*;
+import com.ibm.icu.text.SimpleDateFormat;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -316,8 +317,10 @@ public class TimeZoneTest extends TestFmwk
TimeZone zone = TimeZone.getTimeZone("PST");
String name = zone.getDisplayName(Locale.ENGLISH);
logln("PST->" + name);
- if (!name.equals("Pacific Standard Time"))
- errln("Fail: Expected \"Pacific Standard Time\", got " + name +
+
+ // dlf - we now (3.4.1) return generic time
+ if (!name.equals("Pacific Time"))
+ errln("Fail: Expected \"Pacific Time\", got " + name +
" for " + zone);
//*****************************************************************
@@ -344,14 +347,16 @@ public class TimeZoneTest extends TestFmwk
// Make sure that we don't display the DST name by constructing a fake
// PST zone that has DST all year long.
+ // dlf - this test is no longer relevant, we display generic time now
+ // so the behavior of the timezone doesn't matter
SimpleTimeZone zone2 = new SimpleTimeZone(0, "PST");
zone2.setStartRule(Calendar.JANUARY, 1, 0);
zone2.setEndRule(Calendar.DECEMBER, 31, 0);
logln("Modified PST inDaylightTime->" + zone2.inDaylightTime(new Date()));
name = zone2.getDisplayName(Locale.ENGLISH);
logln("Modified PST->" + name);
- if (!name.equals("Pacific Standard Time"))
- errln("Fail: Expected \"Pacific Standard Time\"");
+ if (!name.equals("Pacific Time"))
+ errln("Fail: Expected \"Pacific Time\"");
// Make sure we get the default display format for Locales
// with no display name data.
@@ -378,16 +383,18 @@ public class TimeZoneTest extends TestFmwk
if (!name.equals("Pacific Standard Time"))
errln("Fail: Expected Pacific Standard Time for PST in mt_MT but got ");
}
- else if(!name.equals("Pacific Standard Time") &&
+ // dlf - we will use generic time, or if unavailable, GMT for standard time in the zone
+ // - we now (3.4.1) have localizations for this zone, so change test string
+ else if(!name.equals("Los Angeles (Stati Uniti)") &&
!name.equals("GMT-08:00") &&
!name.equals("GMT-8:00") &&
!name.equals("GMT-0800") &&
!name.equals("GMT-800")) {
- errln("Fail: Expected GMT-08:00 or something similar");
- errln("************************************************************");
- errln("THE ABOVE FAILURE MAY JUST MEAN THE LOCALE DATA HAS CHANGED");
- errln("************************************************************");
+ errln("Fail: got '" + name + "', expected GMT-08:00 or something similar\n" +
+ "************************************************************\n" +
+ "THE ABOVE FAILURE MAY JUST MEAN THE LOCALE DATA HAS CHANGED\n" +
+ "************************************************************");
}
// Now try a non-existent zone
@@ -413,6 +420,30 @@ public class TimeZoneTest extends TestFmwk
ULocale.setDefault(save);
}
+
+ public void TestDisplayName2() {
+ // Date now = new Date();
+ Date then = new Date(2005, 0, 1);
+
+ String[] timezones = {"America/Chicago", "Europe/Moscow", "Europe/Rome", "Asia/Shanghai", "WET" };
+ String[] locales = {"en", "fr", "de", "ja", "zh_TW", "zh_Hans" };
+ for (int j = 0; j < locales.length; ++j) {
+ ULocale locale = new ULocale(locales[j]);
+ for (int i = 0; i < timezones.length; ++i) {
+ TimeZone tz = TimeZone.getTimeZone(timezones[i]);
+ String displayName0 = tz.getDisplayName(locale); // doesn't work???
+ SimpleDateFormat dt = new SimpleDateFormat("vvvv", locale);
+ dt.setTimeZone(tz);
+ String displayName1 = dt.format(then); // date value _does_ matter if we fallback to GMT
+ logln(locale.getDisplayName() + ", " + tz.getID() + ": " + displayName0);
+ if (!displayName1.equals(displayName0)) {
+ errln(locale.getDisplayName() + ", " + tz.getID() +
+ ": expected " + displayName1 + " but got: " + displayName0);
+ }
+ }
+ }
+ }
+
public void TestGenericAPI() {
String id = "NewGMT";
int offset = 12345;
diff --git a/icu4j/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java b/icu4j/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java
index 3fba933b5a9..1ccdc36552f 100644
--- a/icu4j/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java
+++ b/icu4j/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java
@@ -6,12 +6,18 @@
*/
package com.ibm.icu.dev.test.util;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.IOException;
import java.net.URL;
+import java.net.URLConnection;
+import java.net.JarURLConnection;
import java.nio.ByteBuffer;
import java.util.MissingResourceException;
import java.util.Enumeration;
+import java.util.jar.JarEntry;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.impl.ICUData;
@@ -25,6 +31,7 @@ import com.ibm.icu.util.UResourceTypeMismatchException;
public final class ICUResourceBundleTest extends TestFmwk {
+ private static final ClassLoader testLoader = ICUResourceBundleTest.class.getClassLoader();
public static void main(String args[]) throws Exception {
ICUResourceBundleTest test = new ICUResourceBundleTest();
@@ -33,26 +40,34 @@ public final class ICUResourceBundleTest extends TestFmwk {
}
public void TestGetResources(){
try{
- ClassLoader loader = getClass().getClassLoader();
- Enumeration en = loader.getResources("META-INF");
- for(;en.hasMoreElements();){
- //URL url = loader.getResource("LocaleElements_en.class");
- //File file = new File(url.getPath());
+ Enumeration en = testLoader.getResources("META-INF");
+ for(;en.hasMoreElements();) {
URL url = (URL)en.nextElement();
- if (url == null) {
- warnln("could not load resource data");
- return;
- }
- File file = new File(url.getPath());
- File[] files = file.listFiles();
- if(files!=null){
- for(int i=0; i> 28L);
@@ -600,6 +602,9 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
}
private ICUResourceBundle findResource(String key, long resource,
HashMap table, ICUResourceBundle requested) {
+
+ ClassLoader loaderToUse = loader;
+
String locale = null, keyPath = null;
String bundleName;
String resPath = getStringValue(resource);
@@ -623,6 +628,7 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
//there is a path included
if (bundleName.equals(ICUDATA)) {
bundleName = ICU_BASE_NAME;
+ loaderToUse = ICU_DATA_CLASS_LOADER;
}
} else {
//no path start with locale
@@ -643,11 +649,12 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
keyPath = resPath.substring(LOCALE.length() + 2/* prepending and appending / */, resPath.length());
locale = requested.getLocaleID();
}else if (locale == null) {
+ // {dlf} must use requestor's class loader to get resources from same jar
bundle = (ICUResourceBundle) getBundleInstance(bundleName, "",
- ICU_DATA_CLASS_LOADER, false);
+ loaderToUse, false);
} else {
bundle = (ICUResourceBundle) getBundleInstance(bundleName, locale,
- ICU_DATA_CLASS_LOADER, false);
+ loaderToUse, false);
}
ICUResourceBundle sub = null;
if (keyPath != null) {
diff --git a/icu4j/src/com/ibm/icu/impl/OlsonTimeZone.java b/icu4j/src/com/ibm/icu/impl/OlsonTimeZone.java
index 5a57ead8248..1286430127c 100644
--- a/icu4j/src/com/ibm/icu/impl/OlsonTimeZone.java
+++ b/icu4j/src/com/ibm/icu/impl/OlsonTimeZone.java
@@ -685,7 +685,7 @@ public class OlsonTimeZone extends TimeZone {
transitionCount ^ (transitionCount>>>6) +
typeCount ^ (typeCount>>>8) +
Double.doubleToLongBits(finalMillis)+
- finalZone.hashCode() +
+ (finalZone == null ? 0 : finalZone.hashCode()) +
super.hashCode());
for(int i=0; i>>8);
diff --git a/icu4j/src/com/ibm/icu/impl/ZoneMeta.java b/icu4j/src/com/ibm/icu/impl/ZoneMeta.java
index ae177936e0f..c765dff97b1 100644
--- a/icu4j/src/com/ibm/icu/impl/ZoneMeta.java
+++ b/icu4j/src/com/ibm/icu/impl/ZoneMeta.java
@@ -284,15 +284,14 @@ public final class ZoneMeta {
String country_code = info[1];
if (country_code == null) {
- return null; // error!
+ return null; // error!
}
String country = null;
if (country_code != null) {
ICUResourceBundle rb =
(ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
- String rblocname = rb.getULocale().getBaseName();
- if (LocaleUtility.isFallbackOf(rblocname, locale.getBaseName())) {
+ if (rb.getLoadingStatus() != rb.FROM_ROOT && rb.getLoadingStatus() != rb.FROM_DEFAULT) {
country = ULocale.getDisplayCountry("xx_" + country_code, locale);
}
if (country == null || country.length() == 0) country = country_code;
diff --git a/icu4j/src/com/ibm/icu/text/SimpleDateFormat.java b/icu4j/src/com/ibm/icu/text/SimpleDateFormat.java
index 5456321cd09..1178dbd0bb2 100755
--- a/icu4j/src/com/ibm/icu/text/SimpleDateFormat.java
+++ b/icu4j/src/com/ibm/icu/text/SimpleDateFormat.java
@@ -248,7 +248,6 @@ public class SimpleDateFormat extends DateFormat {
private DateFormatSymbols formatData;
private transient ULocale locale;
- private transient boolean formatDataIsValid;
/**
* We map dates with two-digit years into the century starting at
@@ -459,9 +458,6 @@ public class SimpleDateFormat extends DateFormat {
private void initialize(ULocale loc) {
// time zone formatting
locale = loc;
- this.formatDataIsValid =
- LocaleUtility.isFallbackOf(formatData.getLocale(ULocale.ACTUAL_LOCALE).getBaseName(),
- loc.getBaseName());
// The format object must be constructed using the symbols for this zone.
// However, the calendar should use the current default TimeZone.
@@ -816,6 +812,7 @@ public class SimpleDateFormat extends DateFormat {
case 17: // 'z' - ZONE_OFFSET
case 24: // 'v' - TIMEZONE_GENERIC
{
+
String zid;
String res=null;
zid = ZoneMeta.getCanonicalID(cal.getTimeZone().getID());
diff --git a/icu4j/src/com/ibm/icu/util/TimeZone.java b/icu4j/src/com/ibm/icu/util/TimeZone.java
index 4414ccf2147..059f93e2db6 100755
--- a/icu4j/src/com/ibm/icu/util/TimeZone.java
+++ b/icu4j/src/com/ibm/icu/util/TimeZone.java
@@ -98,6 +98,16 @@ abstract public class TimeZone implements Serializable, Cloneable {
*/
public static final int LONG = 1;
+ /**
+ * @internal
+ */
+ private static final int SHORT_GENERIC = 2;
+
+ /**
+ * @internal
+ */
+ private static final int LONG_GENERIC = 3;
+
/**
* Cache to hold the SimpleDateFormat objects for a Locale.
*/
@@ -368,31 +378,29 @@ abstract public class TimeZone implements Serializable, Cloneable {
/**
* Returns a name of this time zone suitable for presentation to the user
* in the default locale.
- * This method returns the long name, not including daylight savings.
+ * This method returns the long generic name.
* If the display name is not available for the locale,
- * then this method returns a string in the format
- * GMT[+-]hh:mm
.
+ * a fallback based on the country, city, or time zone id will be used.
* @return the human-readable name of this time zone in the default locale.
* @stable ICU 2.0
*/
public final String getDisplayName() {
- return getDisplayName(false, LONG, ULocale.getDefault());
+ return _getDisplayName(false, LONG_GENERIC, ULocale.getDefault());
}
/**
* Returns a name of this time zone suitable for presentation to the user
* in the specified locale.
- * This method returns the long name, not including daylight savings.
+ * This method returns the long generic name.
* If the display name is not available for the locale,
- * then this method returns a string in the format
- * GMT[+-]hh:mm
.
+ * a fallback based on the country, city, or time zone id will be used.
* @param locale the locale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale
* or in the default locale if the given locale is not recognized.
* @stable ICU 2.0
*/
public final String getDisplayName(Locale locale) {
- return getDisplayName(false, LONG, ULocale.forLocale(locale));
+ return _getDisplayName(false, LONG_GENERIC, ULocale.forLocale(locale));
}
/**
@@ -400,8 +408,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* in the specified locale.
* This method returns the long name, not including daylight savings.
* If the display name is not available for the locale,
- * then this method returns a string in the format
- * GMT[+-]hh:mm
.
+ * a fallback based on the country, city, or time zone id will be used.
* @param locale the ulocale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale
* or in the default ulocale if the given ulocale is not recognized.
@@ -409,7 +416,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* @deprecated This is a draft API and might change in a future release of ICU.
*/
public final String getDisplayName(ULocale locale) {
- return getDisplayName(false, LONG, locale);
+ return _getDisplayName(false, LONG_GENERIC, locale);
}
/**
@@ -461,6 +468,18 @@ abstract public class TimeZone implements Serializable, Cloneable {
* @deprecated This is a draft API and might change in a future release of ICU.
*/
public String getDisplayName(boolean daylight, int style, ULocale locale) {
+ if (style != SHORT && style != LONG) {
+ throw new IllegalArgumentException("Illegal style: " + style);
+ }
+ return _getDisplayName(daylight, style, locale);
+ }
+
+ /**
+ * The public version of this API only accepts LONG/SHORT, the
+ * internal version (which this calls) also accepts LONG_GENERIC/SHORT_GENERIC.
+ * @internal
+ */
+ private String _getDisplayName(boolean daylight, int style, ULocale locale) {
/* NOTES:
* (1) We use SimpleDateFormat for simplicity; we could do this
* more efficiently but it would duplicate the SimpleDateFormat code
@@ -471,9 +490,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* locale upon resurrection; and to somehow handle the special case of
* construction from a DateFormatSymbols object.
*/
- if (style != SHORT && style != LONG) {
- throw new IllegalArgumentException("Illegal style: " + style);
- }
+
// We keep a cache, indexed by locale. The cache contains a
// SimpleDateFormat object, which we create on demand.
SoftReference data = (SoftReference)cachedLocaleData.get(locale);
@@ -497,7 +514,8 @@ abstract public class TimeZone implements Serializable, Cloneable {
} else {
tz = new SimpleTimeZone(getRawOffset(), getID());
}
- format.applyPattern(style == LONG ? "zzzz" : "z");
+ String[] patterns = { "z", "zzzz", "v", "vvvv" };
+ format.applyPattern(patterns[style]);
format.setTimeZone(tz);
// Format a date in January. We use the value 10*ONE_DAY == Jan 11 1970
// 0:00 GMT.
diff --git a/icu4j/src/com/ibm/icu/util/ULocale.java b/icu4j/src/com/ibm/icu/util/ULocale.java
index 27cff40bb81..f672719f21c 100644
--- a/icu4j/src/com/ibm/icu/util/ULocale.java
+++ b/icu4j/src/com/ibm/icu/util/ULocale.java
@@ -724,7 +724,7 @@ public final class ULocale implements Serializable {
/**
* Construct a ULocale object from a {@link java.util.Locale}.
* @param loc a JDK locale
- * @draft ICU 2.8
+ * @stable ICU 2.8
* @internal
*/
private ULocale(Locale loc) {
@@ -2626,7 +2626,6 @@ public final class ULocale implements Serializable {
availableLocales, boolean[] fallback) {
/**
* @internal ICU 3.4
- * @deprecated this is an internal class
*/
class ULocaleAcceptLanguageQ implements Comparable {
private double q;