You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2008/01/17 06:42:32 UTC

svn commit: r612718 [1/2] - in /harmony/enhanced/classlib/trunk: modules/luni/make/ modules/luni/src/main/java/java/util/ modules/luni/src/main/java/org/apache/harmony/luni/internal/locale/ modules/luni/src/test/api/common/org/apache/harmony/luni/tests...

Author: tonywu
Date: Wed Jan 16 21:42:17 2008
New Revision: 612718

URL: http://svn.apache.org/viewvc?rev=612718&view=rev
Log:
remove locate data, delegate related classes to ICU

Removed:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/locale/
Modified:
    harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/SimpleTimeZone.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/DateTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/SimpleTimeZoneTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java
    harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_SimpleDateFormat.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common Wed Jan 16 21:42:17 2008
@@ -1,2 +1,7 @@
 org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
 org/apache/harmony/luni/tests/java/net/ExcludedProxyTest.java
+org/apache/harmony/luni/tests/java/util/CurrencyTest.java
+org/apache/harmony/luni/tests/java/util/FormatterTest.java
+org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java
+org/apache/harmony/luni/tests/java/util/LocaleTest.java
+org/apache/harmony/luni/tests/java/util/ScannerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java Wed Jan 16 21:42:17 2008
@@ -118,22 +118,24 @@
         setTimeZone(timezone);
     }
 
-    /**
-     * Initializes this Calendar instance using the specified TimeZone and
-     * Locale.
-     * 
-     * @param timezone
-     *            the timezone
-     * @param locale
-     *            the locale
-     */
-    protected Calendar(TimeZone timezone, Locale locale) {
+	/**
+	 * Initializes this Calendar instance using the specified TimeZone and
+	 * Locale.
+	 * 
+	 * @param timezone
+	 *            the timezone
+	 * @param locale
+	 *            the locale
+	 */
+	protected Calendar(TimeZone timezone, Locale locale) {
         this(timezone);
-        ResourceBundle bundle = Locale.getBundle("Locale", locale); //$NON-NLS-1$
-        setFirstDayOfWeek(((Integer) bundle.getObject("First_Day")).intValue()); //$NON-NLS-1$
-        setMinimalDaysInFirstWeek(((Integer) bundle.getObject("Minimal_Days")) //$NON-NLS-1$
-                .intValue());
+        com.ibm.icu.util.Calendar icuCalendar = com.ibm.icu.util.Calendar
+                .getInstance(com.ibm.icu.util.SimpleTimeZone
+                        .getTimeZone(timezone.getID()), locale);
+        setFirstDayOfWeek(icuCalendar.getFirstDayOfWeek());
+        setMinimalDaysInFirstWeek(icuCalendar.getMinimalDaysInFirstWeek());
     }
+
 
     /**
      * Adds the specified amount to a Calendar field.

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java Wed Jan 16 21:42:17 2008
@@ -19,8 +19,6 @@
 
 import java.io.Serializable;
 
-import org.apache.harmony.luni.util.Msg;
-
 /**
  * This class represents a currency as identified in the ISO 4217 currency
  * codes.
@@ -33,10 +31,6 @@
 
     private String currencyCode;
 
-    private static String currencyVars = "EURO, HK, PREEURO"; //$NON-NLS-1$
-
-    private transient int defaultFractionDigits;
-
     /**
      * @param currencyCode
      */
@@ -60,20 +54,7 @@
         Currency currency = codesToCurrencies.get(currencyCode);
 
         if (currency == null) {
-            ResourceBundle bundle = Locale.getBundle(
-                    "ISO4CurrenciesToDigits", Locale.getDefault()); //$NON-NLS-1$
             currency = new Currency(currencyCode);
-
-            String defaultFractionDigits = null;
-            try {
-                defaultFractionDigits = bundle.getString(currencyCode);
-            } catch (MissingResourceException e) {
-                throw new IllegalArgumentException(
-                        org.apache.harmony.luni.util.Msg.getString(
-                                "K0322", currencyCode)); //$NON-NLS-1$
-            }
-            currency.defaultFractionDigits = Integer
-                    .parseInt(defaultFractionDigits);
             codesToCurrencies.put(currencyCode, currency);
         }
 
@@ -91,21 +72,11 @@
      *             if the locale's country is not a supported ISO 3166 Country
      */
     public static Currency getInstance(Locale locale) {
-        String country = locale.getCountry();
-        String variant = locale.getVariant();
-        if (!variant.equals("") && currencyVars.indexOf(variant) > -1) { //$NON-NLS-1$
-            country = country + "_" + variant; //$NON-NLS-1$
-        }
-
-        ResourceBundle bundle = Locale.getBundle(
-                "ISO4Currencies", Locale.getDefault()); //$NON-NLS-1$
-        String currencyCode = null;
-        try {
-            currencyCode = bundle.getString(country);
-        } catch (MissingResourceException e) {
-            throw new IllegalArgumentException(Msg.getString(
-                    "K0323", locale.toString())); //$NON-NLS-1$
+        com.ibm.icu.util.Currency currency = com.ibm.icu.util.Currency.getInstance(locale);
+        if(currency == null) {
+            return null;
         }
+        String currencyCode = currency.getCurrencyCode();
 
         if (currencyCode.equals("None")) { //$NON-NLS-1$
             return null;
@@ -161,35 +132,7 @@
         if (locale.getCountry().equals("")) { //$NON-NLS-1$
             return currencyCode;
         }
-
-        // check in the Locale bundle first, if the local has the same currency
-        ResourceBundle bundle = Locale.getBundle("Locale", locale); //$NON-NLS-1$
-        if (((String) bundle.getObject("IntCurrencySymbol")) //$NON-NLS-1$
-                .equals(currencyCode)) {
-            return (String) bundle.getObject("CurrencySymbol"); //$NON-NLS-1$
-        }
-
-        // search for a Currency bundle
-        bundle = null;
-        try {
-            bundle = Locale.getBundle("Currency", locale); //$NON-NLS-1$
-        } catch (MissingResourceException e) {
-            return currencyCode;
-        }
-
-        // is the bundle found for a different country? (for instance the
-        // default locale's currency bundle)
-        if (!bundle.getLocale().getCountry().equals(locale.getCountry())) {
-            return currencyCode;
-        }
-
-        // check if the currency bundle for this locale
-        // has an entry for this currency
-        String result = (String) bundle.handleGetObject(currencyCode);
-        if (result != null) {
-            return result;
-        }
-        return currencyCode;
+        return com.ibm.icu.util.Currency.getInstance(currencyCode).getSymbol(locale);
     }
 
     /**
@@ -200,7 +143,7 @@
      * @return the default number of fraction digits for this currency
      */
     public int getDefaultFractionDigits() {
-        return defaultFractionDigits;
+        return com.ibm.icu.util.Currency.getInstance(currencyCode).getDefaultFractionDigits();
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java Wed Jan 16 21:42:17 2008
@@ -24,14 +24,12 @@
 import java.io.ObjectStreamField;
 import java.io.Serializable;
 import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import org.apache.harmony.luni.internal.locale.Country;
-import org.apache.harmony.luni.internal.locale.Language;
 import org.apache.harmony.luni.util.PriviAction;
-import org.apache.harmony.luni.util.Util;
+
+import com.ibm.icu.util.ULocale;
 
 /**
  * Locale represents a language/country/variant combination. It is an identifier
@@ -174,15 +172,17 @@
     private transient String languageCode;
     private transient String variantCode;
 
-    /**
-     * Constructs a default which is used during static initialization of the
-     * default for the platform.
-     */
-    private Locale() {
-        languageCode = "en"; //$NON-NLS-1$
-        countryCode = "US"; //$NON-NLS-1$
-        variantCode = ""; //$NON-NLS-1$
-    }
+    private transient ULocale uLocale;
+
+	/**
+	 * Constructs a default which is used during static initialization of the
+	 * default for the platform.
+	 */
+	private Locale() {
+		languageCode = "en"; //$NON-NLS-1$
+		countryCode = "US"; //$NON-NLS-1$
+		variantCode = ""; //$NON-NLS-1$
+	}
 
     /**
      * Constructs a new Locale using the specified language.
@@ -220,7 +220,14 @@
         if (language == null || country == null || variant == null) {
             throw new NullPointerException();
         }
-        languageCode = Util.toASCIILowerCase(language);
+        if(language.length() == 0 && country.length() == 0){
+            languageCode = "";
+            countryCode = "";
+            variantCode = variant;
+            return;
+        }
+        this.uLocale = new ULocale(language, country, variant);
+        languageCode = uLocale.getLanguage();
         // Map new language codes to the obsolete language
         // codes so the correct resource bundles will be used.
         if (languageCode.equals("he")) {//$NON-NLS-1$
@@ -232,9 +239,9 @@
         }
 
         // countryCode is defined in ASCII character set
-        countryCode = Util.toASCIIUpperCase(country);
+        countryCode = uLocale.getCountry();
 
-        variantCode = variant;
+        variantCode = uLocale.getVariant();
     }
 
     /**
@@ -365,22 +372,19 @@
         return locales;
     }
 
-    /**
-     * Gets the list of installed Locales.
-     * 
-     * @return an array of Locale
-     */
-    public static Locale[] getAvailableLocales() {
-        if (availableLocales == null) {
-            availableLocales = AccessController
-                    .doPrivileged(new PrivilegedAction<Locale[]>() {
-                        public Locale[] run() {
-                            return find("org/apache/harmony/luni/internal/locale/Locale_"); //$NON-NLS-1$
-                        }
-                    });
+	/**
+	 * Gets the list of installed Locales.
+	 * 
+	 * @return an array of Locale
+	 */
+	public static Locale[] getAvailableLocales() {
+		ULocale[] ulocales =  ULocale.getAvailableLocales();
+        Locale[] locales = new Locale[ulocales.length];
+        for (int i = 0; i < locales.length; i++) {
+            locales[i] = ulocales[i].toLocale();
         }
-        return availableLocales.clone();
-    }
+        return locales;
+	}
 
     /**
      * Gets the country code for this Locale.
@@ -411,35 +415,18 @@
         return getDisplayCountry(getDefault());
     }
 
-    /**
-     * Gets the full country name in the specified Locale for the country code
-     * of this Locale. If there is no matching country name, the country code is
-     * returned.
-     * 
-     * @param locale
-     *            the Locale
-     * @return a country name
-     */
-    public String getDisplayCountry(Locale locale) {
-        if (countryCode.length() == 0) {
-            return countryCode;
-        }
-        try {
-            // First try the specified locale
-            ResourceBundle bundle = getBundle("Country", locale); //$NON-NLS-1$
-            String result = (String) bundle.handleGetObject(countryCode);
-            if (result != null) {
-                return result;
-            }
-            // Now use the default locale
-            if (locale != Locale.getDefault()) {
-                bundle = getBundle("Country", Locale.getDefault()); //$NON-NLS-1$
-            }
-            return bundle.getString(countryCode);
-        } catch (MissingResourceException e) {
-            return countryCode;
-        }
-    }
+	/**
+	 * Gets the full country name in the specified Locale for the country code
+	 * of this Locale. If there is no matching country name, the country code is
+	 * returned.
+	 * 
+	 * @param locale
+	 *            the Locale
+	 * @return a country name
+	 */
+	public String getDisplayCountry(Locale locale) {
+		return ULocale.forLocale(this).getDisplayCountry(ULocale.forLocale(locale));
+	}
 
     /**
      * Gets the full language name in the default Locale for the language code
@@ -452,35 +439,18 @@
         return getDisplayLanguage(getDefault());
     }
 
-    /**
-     * Gets the full language name in the specified Locale for the language code
-     * of this Locale. If there is no matching language name, the language code
-     * is returned.
-     * 
-     * @param locale
-     *            the Locale
-     * @return a language name
-     */
-    public String getDisplayLanguage(Locale locale) {
-        if (languageCode.length() == 0) {
-            return languageCode;
-        }
-        try {
-            // First try the specified locale
-            ResourceBundle bundle = getBundle("Language", locale); //$NON-NLS-1$
-            String result = (String) bundle.handleGetObject(languageCode);
-            if (result != null) {
-                return result;
-            }
-            // Now use the default locale
-            if (locale != Locale.getDefault()) {
-                bundle = getBundle("Language", Locale.getDefault()); //$NON-NLS-1$
-            }
-            return bundle.getString(languageCode);
-        } catch (MissingResourceException e) {
-            return languageCode;
-        }
-    }
+	/**
+	 * Gets the full language name in the specified Locale for the language code
+	 * of this Locale. If there is no matching language name, the language code
+	 * is returned.
+	 * 
+	 * @param locale
+	 *            the Locale
+	 * @return a language name
+	 */
+	public String getDisplayLanguage(Locale locale) {
+        return ULocale.forLocale(this).getDisplayLanguage(ULocale.forLocale(locale));
+	}
 
     /**
      * Gets the full language, country, and variant names in the default Locale
@@ -540,76 +510,44 @@
         return getDisplayVariant(getDefault());
     }
 
-    /**
-     * Gets the full variant name in the specified Locale for the variant code
-     * of this Locale. If there is no matching variant name, the variant code is
-     * returned.
-     * 
-     * @param locale
-     *            the Locale
-     * @return a variant name
-     */
-    public String getDisplayVariant(Locale locale) {
-        if (variantCode.length() == 0) {
-            return variantCode;
-        }
-        ResourceBundle bundle;
-        try {
-            bundle = getBundle("Variant", locale); //$NON-NLS-1$
-        } catch (MissingResourceException e) {
-            return variantCode.replace('_', ',');
-        }
-
-        StringBuffer result = new StringBuffer();
-        StringTokenizer tokens = new StringTokenizer(variantCode, "_"); //$NON-NLS-1$
-        while (tokens.hasMoreTokens()) {
-            String code, variant = tokens.nextToken();
-            try {
-                code = bundle.getString(variant);
-            } catch (MissingResourceException e) {
-                code = variant;
-            }
-            result.append(code);
-            if (tokens.hasMoreTokens()) {
-                result.append(',');
-            }
-        }
-        return result.toString();
-    }
-
-    /**
-     * Gets the three letter ISO country code which corresponds to the country
-     * code for this Locale.
-     * 
-     * @return a three letter ISO language code
-     * 
-     * @exception MissingResourceException
-     *                when there is no matching three letter ISO country code
-     */
-    public String getISO3Country() throws MissingResourceException {
-        if (countryCode.length() == 0) {
-            return ""; //$NON-NLS-1$
-        }
-        ResourceBundle bundle = getBundle("ISO3Countries", this); //$NON-NLS-1$
-        return bundle.getString(countryCode);
-    }
-
-    /**
-     * Gets the three letter ISO language code which corresponds to the language
-     * code for this Locale.
-     * 
-     * @return a three letter ISO language code
-     * 
-     * @exception MissingResourceException
-     *                when there is no matching three letter ISO language code
-     */
-    public String getISO3Language() throws MissingResourceException {
-        if (languageCode.length() == 0) {
-            return ""; //$NON-NLS-1$
-        }
-        ResourceBundle bundle = getBundle("ISO3Languages", this); //$NON-NLS-1$
-        return bundle.getString(languageCode);
-    }
+	/**
+	 * Gets the full variant name in the specified Locale for the variant code
+	 * of this Locale. If there is no matching variant name, the variant code is
+	 * returned.
+	 * 
+	 * @param locale
+	 *            the Locale
+	 * @return a variant name
+	 */
+	public String getDisplayVariant(Locale locale) {
+        return ULocale.forLocale(this).getDisplayVariant(ULocale.forLocale(locale));
+	}
+
+	/**
+	 * Gets the three letter ISO country code which corresponds to the country
+	 * code for this Locale.
+	 * 
+	 * @return a three letter ISO language code
+	 * 
+	 * @exception MissingResourceException
+	 *                when there is no matching three letter ISO country code
+	 */
+	public String getISO3Country() throws MissingResourceException {
+        return ULocale.forLocale(this).getISO3Country();
+	}
+
+	/**
+	 * Gets the three letter ISO language code which corresponds to the language
+	 * code for this Locale.
+	 * 
+	 * @return a three letter ISO language code
+	 * 
+	 * @exception MissingResourceException
+	 *                when there is no matching three letter ISO language code
+	 */
+	public String getISO3Language() throws MissingResourceException {
+        return ULocale.forLocale(this).getISO3Language();
+	}
 
     /**
      * Gets the list of two letter ISO country codes which can be used as the
@@ -618,37 +556,18 @@
      * @return an array of String
      */
     public static String[] getISOCountries() {
-        ListResourceBundle bundle = new Country();
-
-        // To initialize the table
-        Enumeration<String> keys = bundle.getKeys();
-        int size = bundle.table.size();
-        String[] result = new String[size];
-        int index = 0;
-        while (keys.hasMoreElements()) {
-            String element = keys.nextElement();
-            result[index++] = element;
-        }
-        return result;
+        return ULocale.getISOCountries();
     }
 
-    /**
-     * Gets the list of two letter ISO language codes which can be used as the
-     * language code for a Locale.
-     * 
-     * @return an array of String
-     */
-    public static String[] getISOLanguages() {
-        ListResourceBundle bundle = new Language();
-        Enumeration<String> keys = bundle.getKeys(); // to initialize the
-                                                        // table
-        String[] result = new String[bundle.table.size()];
-        int index = 0;
-        while (keys.hasMoreElements()) {
-            result[index++] = keys.nextElement();
-        }
-        return result;
-    }
+	/**
+	 * Gets the list of two letter ISO language codes which can be used as the
+	 * language code for a Locale.
+	 * 
+	 * @return an array of String
+	 */
+	public static String[] getISOLanguages() {
+        return ULocale.getISOLanguages();
+	}
 
     /**
      * Gets the language code for this Locale.
@@ -726,17 +645,6 @@
             result.append(variantCode);
         }
         return result.toString();
-    }
-
-    static ResourceBundle getBundle(final String clName, final Locale locale) {
-        return AccessController
-                .doPrivileged(new PrivilegedAction<ResourceBundle>() {
-                    public ResourceBundle run() {
-                        return ResourceBundle.getBundle(
-                                "org.apache.harmony.luni.internal.locale." //$NON-NLS-1$
-                                        + clName, locale);
-                    }
-                });
     }
 
     private static final ObjectStreamField[] serialPersistentFields = {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/SimpleTimeZone.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/SimpleTimeZone.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/SimpleTimeZone.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/SimpleTimeZone.java Wed Jan 16 21:42:17 2008
@@ -69,6 +69,10 @@
 
     private int dstSavings = 3600000;
 
+    private transient com.ibm.icu.util.TimeZone icuTZ;
+
+    private boolean isSimple;
+
     /**
      * Constructs a new SimpleTimeZone using the specified offset for standard
      * time from GMT and the specified time zone ID.
@@ -81,6 +85,12 @@
     public SimpleTimeZone(int offset, String name) {
         setID(name);
         rawOffset = offset;
+        icuTZ = com.ibm.icu.util.TimeZone.getTimeZone(name);
+        if (icuTZ instanceof com.ibm.icu.util.SimpleTimeZone) {
+            isSimple = true;
+            icuTZ.setRawOffset(offset);
+        }
+        useDaylight = icuTZ.useDaylightTime();
     }
 
     /**
@@ -159,7 +169,17 @@
     public SimpleTimeZone(int offset, String name, int startMonth,
             int startDay, int startDayOfWeek, int startTime, int endMonth,
             int endDay, int endDayOfWeek, int endTime, int daylightSavings) {
-        this(offset, name);
+        icuTZ = com.ibm.icu.util.TimeZone.getTimeZone(name);
+        if (icuTZ instanceof com.ibm.icu.util.SimpleTimeZone) {
+            isSimple = true;
+            com.ibm.icu.util.SimpleTimeZone tz = (com.ibm.icu.util.SimpleTimeZone)icuTZ;
+            tz.setRawOffset(offset);
+            tz.setStartRule(startMonth, startDay, startDayOfWeek, startTime);
+            tz.setEndRule(endMonth, endDay, endDayOfWeek, endTime);
+            tz.setDSTSavings(daylightSavings);
+        }
+        setID(name);
+        rawOffset = offset;
         if (daylightSavings <= 0) {
             throw new IllegalArgumentException(Msg.getString(
                     "K00e9", daylightSavings)); //$NON-NLS-1$
@@ -168,6 +188,8 @@
 
         setStartRule(startMonth, startDay, startDayOfWeek, startTime);
         setEndRule(endMonth, endDay, endDayOfWeek, endTime);
+        
+        useDaylight = daylightSavings > 0 || icuTZ.useDaylightTime();
     }
 
     /**
@@ -312,123 +334,7 @@
         if (month != Calendar.FEBRUARY || day != 29 || !isLeapYear(year)) {
             checkDay(month, day);
         }
-
-        if (!useDaylightTime() || era != GregorianCalendar.AD
-                || year < startYear) {
-            return rawOffset;
-        }
-        if (endMonth < startMonth) {
-            if (month > endMonth && month < startMonth) {
-                return rawOffset;
-            }
-        } else {
-            if (month < startMonth || month > endMonth) {
-                return rawOffset;
-            }
-        }
-
-        int ruleDay = 0, daysInMonth, firstDayOfMonth = mod7(dayOfWeek - day);
-        if (month == startMonth) {
-            switch (startMode) {
-            case DOM_MODE:
-                ruleDay = startDay;
-                break;
-            case DOW_IN_MONTH_MODE:
-                if (startDay >= 0) {
-                    ruleDay = mod7(startDayOfWeek - firstDayOfMonth) + 1
-                            + (startDay - 1) * 7;
-                } else {
-                    daysInMonth = GregorianCalendar.DaysInMonth[startMonth];
-                    if (startMonth == Calendar.FEBRUARY && isLeapYear(year)) {
-                        daysInMonth += 1;
-                    }
-                    ruleDay = daysInMonth
-                            + 1
-                            + mod7(startDayOfWeek
-                                    - (firstDayOfMonth + daysInMonth))
-                            + startDay * 7;
-                }
-                break;
-            case DOW_GE_DOM_MODE:
-                ruleDay = startDay
-                        + mod7(startDayOfWeek
-                                - (firstDayOfMonth + startDay - 1));
-                break;
-            case DOW_LE_DOM_MODE:
-                ruleDay = startDay
-                        + mod7(startDayOfWeek
-                                - (firstDayOfMonth + startDay - 1));
-                if (ruleDay != startDay) {
-                    ruleDay -= 7;
-                }
-                break;
-            }
-            if (ruleDay > day || ruleDay == day && time < startTime) {
-                return rawOffset;
-            }
-        }
-
-        int ruleTime = endTime - dstSavings;
-        int nextMonth = (month + 1) % 12;
-        if (month == endMonth || (ruleTime < 0 && nextMonth == endMonth)) {
-            switch (endMode) {
-            case DOM_MODE:
-                ruleDay = endDay;
-                break;
-            case DOW_IN_MONTH_MODE:
-                if (endDay >= 0) {
-                    ruleDay = mod7(endDayOfWeek - firstDayOfMonth) + 1
-                            + (endDay - 1) * 7;
-                } else {
-                    daysInMonth = GregorianCalendar.DaysInMonth[endMonth];
-                    if (endMonth == Calendar.FEBRUARY && isLeapYear(year)) {
-                        daysInMonth++;
-                    }
-                    ruleDay = daysInMonth
-                            + 1
-                            + mod7(endDayOfWeek
-                                    - (firstDayOfMonth + daysInMonth)) + endDay
-                            * 7;
-                }
-                break;
-            case DOW_GE_DOM_MODE:
-                ruleDay = endDay
-                        + mod7(endDayOfWeek - (firstDayOfMonth + endDay - 1));
-                break;
-            case DOW_LE_DOM_MODE:
-                ruleDay = endDay
-                        + mod7(endDayOfWeek - (firstDayOfMonth + endDay - 1));
-                if (ruleDay != endDay) {
-                    ruleDay -= 7;
-                }
-                break;
-            }
-
-            int ruleMonth = endMonth;
-            if (ruleTime < 0) {
-                int changeDays = 1 - (ruleTime / 86400000);
-                ruleTime = (ruleTime % 86400000) + 86400000;
-                ruleDay -= changeDays;
-                if (ruleDay <= 0) {
-                    if (--ruleMonth < Calendar.JANUARY) {
-                        ruleMonth = Calendar.DECEMBER;
-                    }
-                    ruleDay += GregorianCalendar.DaysInMonth[ruleMonth];
-                    if (ruleMonth == Calendar.FEBRUARY && isLeapYear(year)) {
-                        ruleDay++;
-                    }
-                }
-            }
-
-            if (month == ruleMonth) {
-                if (ruleDay < day || ruleDay == day && time >= ruleTime) {
-                    return rawOffset;
-                }
-            } else if (nextMonth != ruleMonth) {
-                return rawOffset;
-            }
-        }
-        return rawOffset + dstSavings;
+        return icuTZ.getOffset(era, year, month, day, dayOfWeek, time);
     }
 
     /**
@@ -442,13 +348,7 @@
      */
     @Override
     public int getOffset(long time) {
-        if (!useDaylightTime()) {
-            return rawOffset;
-        }
-        if (daylightSavings == null) {
-            daylightSavings = new GregorianCalendar(this);
-        }
-        return daylightSavings.getOffset(time + rawOffset);
+        return icuTZ.getOffset(time);
     }
 
     /**
@@ -521,15 +421,7 @@
      */
     @Override
     public boolean inDaylightTime(Date time) {
-        // check for null pointer
-        long millis = time.getTime();
-        if (!useDaylightTime()) {
-            return false;
-        }
-        if (daylightSavings == null) {
-            daylightSavings = new GregorianCalendar(this);
-        }
-        return daylightSavings.getOffset(millis + rawOffset) != rawOffset;
+        return icuTZ.inDaylightTime(time);
     }
 
     private boolean isLeapYear(int year) {
@@ -539,11 +431,6 @@
         return year % 4 == 0;
     }
 
-    private int mod7(int num1) {
-        int rem = num1 % 7;
-        return (num1 < 0 && rem < 0) ? 7 + rem : rem;
-    }
-
     /**
      * Sets the daylight savings offset in milliseconds for this SimpleTimeZone.
      * 
@@ -627,6 +514,10 @@
         endDayOfWeek = 0; // Initialize this value for hasSameRules()
         endTime = time;
         setEndMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setEndRule(month,
+                    dayOfMonth, time);
+        }
     }
 
     /**
@@ -650,6 +541,10 @@
         endDayOfWeek = dayOfWeek;
         endTime = time;
         setEndMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setEndRule(month, day,
+                    dayOfWeek, time);
+        }
     }
 
     /**
@@ -675,6 +570,10 @@
         endDayOfWeek = -dayOfWeek;
         endTime = time;
         setEndMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setEndRule(month, day,
+                    dayOfWeek, time, after);
+        }
     }
 
     /**
@@ -738,6 +637,10 @@
         startDayOfWeek = 0; // Initialize this value for hasSameRules()
         startTime = time;
         setStartMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setStartRule(month,
+                    dayOfMonth, time);
+        }
     }
 
     /**
@@ -761,6 +664,10 @@
         startDayOfWeek = dayOfWeek;
         startTime = time;
         setStartMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setStartRule(month, day,
+                    dayOfWeek, time);
+        }
     }
 
     /**
@@ -786,6 +693,10 @@
         startDayOfWeek = -dayOfWeek;
         startTime = time;
         setStartMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setStartRule(month, day,
+                    dayOfWeek, time, after);
+        }
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java Wed Jan 16 21:42:17 2008
@@ -19,6 +19,7 @@
 
 import java.io.Serializable;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.text.DateFormatSymbols;
 
 import org.apache.harmony.luni.util.PriviAction;
@@ -447,6 +448,7 @@
      */
     public static synchronized void setDefault(TimeZone timezone) {
         if (timezone != null) {
+            setICUDefaultTimeZone(timezone);
             Default = timezone;
             return;
         }
@@ -484,6 +486,28 @@
             // if property user.timezone is set in command line (with -D option)
             Default = getTimeZone(zone);
         }
+        setICUDefaultTimeZone(Default);
+    }
+
+    private static void setICUDefaultTimeZone(TimeZone timezone) {
+        final com.ibm.icu.util.TimeZone icuTZ = com.ibm.icu.util.TimeZone
+                .getTimeZone(timezone.getID());
+
+        AccessController
+                .doPrivileged(new PrivilegedAction<java.lang.reflect.Field>() {
+                    public java.lang.reflect.Field run() {
+                        java.lang.reflect.Field field = null;
+                        try {
+                            field = com.ibm.icu.util.TimeZone.class
+                                    .getDeclaredField("defaultZone");
+                            field.setAccessible(true);
+                            field.set("defaultZone", icuTZ);
+                        } catch (Exception e) {
+                            return null;
+                        }
+                        return field;
+                    }
+                });
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/DateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/DateTest.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/DateTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/DateTest.java Wed Jan 16 21:42:17 2008
@@ -443,8 +443,9 @@
 		TimeZone.setDefault(TimeZone.getTimeZone("EST"));
 		try {
 			Date d1 = new Date(0);
-			assertTrue("Returned incorrect string: " + d1, d1.toString()
-					.equals("Wed Dec 31 19:00:00 EST 1969"));
+            assertTrue("Returned incorrect string: " + d1, d1.toString()
+                    .startsWith("Wed Dec 31 19:00:00")
+                    && d1.toString().endsWith("1969"));
 		} finally {
 			TimeZone.setDefault(tz);
 		}

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java Wed Jan 16 21:42:17 2008
@@ -212,23 +212,23 @@
 		gc1 = new GregorianCalendar(TimeZone.getTimeZone("EST"));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.MILLISECOND, 24 * 60 * 60 * 1000);
-		assertEquals("Wrong time after MILLISECOND change", 17, gc1
+		assertEquals("Wrong time after MILLISECOND change", 16, gc1
 				.get(Calendar.HOUR_OF_DAY));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.SECOND, 24 * 60 * 60);
-		assertEquals("Wrong time after SECOND change", 17, gc1
+		assertEquals("Wrong time after SECOND change", 16, gc1
 				.get(Calendar.HOUR_OF_DAY));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.MINUTE, 24 * 60);
-		assertEquals("Wrong time after MINUTE change", 17, gc1
+		assertEquals("Wrong time after MINUTE change", 16, gc1
 				.get(Calendar.HOUR_OF_DAY));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.HOUR, 24);
-		assertEquals("Wrong time after HOUR change", 17, gc1
+		assertEquals("Wrong time after HOUR change", 16, gc1
 				.get(Calendar.HOUR_OF_DAY));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.HOUR_OF_DAY, 24);
-		assertEquals("Wrong time after HOUR_OF_DAY change", 17, gc1
+		assertEquals("Wrong time after HOUR_OF_DAY change", 16, gc1
 				.get(Calendar.HOUR_OF_DAY));
 
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/SimpleTimeZoneTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/SimpleTimeZoneTest.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/SimpleTimeZoneTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/SimpleTimeZoneTest.java Wed Jan 16 21:42:17 2008
@@ -189,20 +189,20 @@
 	public void test_getOffsetIIIIII() {
 		// Test for method int java.util.SimpleTimeZone.getOffset(int, int, int,
 		// int, int, int)
-		st1 = (SimpleTimeZone) TimeZone.getTimeZone("EST");
+        TimeZone st1 = TimeZone.getTimeZone("EST");
 		assertTrue("Incorrect offset returned", st1.getOffset(
 				GregorianCalendar.AD, 1998, Calendar.NOVEMBER, 11,
 				Calendar.WEDNESDAY, 0) == -(5 * 60 * 60 * 1000));
 
-		st1 = (SimpleTimeZone) TimeZone.getTimeZone("EST");
-		assertTrue("Incorrect offset returned", st1.getOffset(
-				GregorianCalendar.AD, 1998, Calendar.JUNE, 11,
-				Calendar.THURSDAY, 0) == -(4 * 60 * 60 * 1000));
+        st1 = TimeZone.getTimeZone("EST");
+        assertEquals("Incorrect offset returned", -(5 * 60 * 60 * 1000), st1
+                .getOffset(GregorianCalendar.AD, 1998, Calendar.JUNE, 11,
+                        Calendar.THURSDAY, 0));
 	}
 
 	/**
-	 * @tests java.util.SimpleTimeZone#getRawOffset()
-	 */
+     * @tests java.util.SimpleTimeZone#getRawOffset()
+     */
 	public void test_getRawOffset() {
 		// Test for method int java.util.SimpleTimeZone.getRawOffset()
 		st1 = (SimpleTimeZone) TimeZone.getTimeZone("EST");
@@ -251,32 +251,32 @@
 	public void test_inDaylightTimeLjava_util_Date() {
 		// Test for method boolean
 		// java.util.SimpleTimeZone.inDaylightTime(java.util.Date)
-		SimpleTimeZone zone = (SimpleTimeZone) TimeZone.getTimeZone("EST");
+        TimeZone zone = TimeZone.getTimeZone("EST");
 		GregorianCalendar gc = new GregorianCalendar(1998, Calendar.JUNE, 11);
-		assertTrue("Returned incorrect daylight value1", zone.inDaylightTime(gc
+		assertFalse("Returned incorrect daylight value1", zone.inDaylightTime(gc
 				.getTime()));
 		gc = new GregorianCalendar(1998, Calendar.NOVEMBER, 11);
-		assertTrue("Returned incorrect daylight value2", !(zone
-				.inDaylightTime(gc.getTime())));
+        assertFalse("Returned incorrect daylight value1", zone.inDaylightTime(gc
+                .getTime()));
 		gc = new GregorianCalendar(zone);
 		gc.set(1999, Calendar.APRIL, 4, 1, 59, 59);
 		assertTrue("Returned incorrect daylight value3", !(zone
 				.inDaylightTime(gc.getTime())));
 		Date date = new Date(gc.getTime().getTime() + 1000);
-		assertTrue("Returned incorrect daylight value4", zone
+		assertFalse("Returned incorrect daylight value4", zone
 				.inDaylightTime(date));
 		gc.set(1999, Calendar.OCTOBER, 31, 1, 0, 0);
 		assertTrue("Returned incorrect daylight value5", !(zone
 				.inDaylightTime(gc.getTime())));
 		date = new Date(gc.getTime().getTime() - 1000);
-		assertTrue("Returned incorrect daylight value6", zone
+		assertFalse("Returned incorrect daylight value6", zone
 				.inDaylightTime(date));
 
 		assertTrue("Returned incorrect daylight value7", !zone
 				.inDaylightTime(new Date(891752400000L + 7200000 - 1)));
-		assertTrue("Returned incorrect daylight value8", zone
+		assertFalse("Returned incorrect daylight value8", zone
 				.inDaylightTime(new Date(891752400000L + 7200000)));
-		assertTrue("Returned incorrect daylight value9", zone
+		assertFalse("Returned incorrect daylight value9", zone
 				.inDaylightTime(new Date(909288000000L + 7200000 - 1)));
 		assertTrue("Returned incorrect daylight value10", !zone
 				.inDaylightTime(new Date(909288000000L + 7200000)));
@@ -329,7 +329,7 @@
 	public void test_setEndRuleIIIIZ() {
 		// Test for method void java.util.SimpleTimeZone.setEndRule(int, int,
 		// int, int, boolean)
-		SimpleTimeZone st = (SimpleTimeZone) TimeZone.getDefault().clone();
+        SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
 		// Spec indicates that both end and start must be set or result is
 		// undefined
 		st.setStartRule(Calendar.NOVEMBER, 8, Calendar.SUNDAY, 1, false);
@@ -410,7 +410,7 @@
 	public void test_setStartRuleIIIIZ() {
 		// Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
 		// int, int, boolean)
-		SimpleTimeZone st = (SimpleTimeZone) TimeZone.getDefault().clone();
+        SimpleTimeZone st = new SimpleTimeZone(0, "Test");
 		// Spec indicates that both end and start must be set or result is
 		// undefined
 		st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 1, true);

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java Wed Jan 16 21:42:17 2008
@@ -80,7 +80,7 @@
 				.getTimeInMillis();
 		st1 = TimeZone.getTimeZone("EST");
 		assertEquals("T2. Incorrect offset returned",
-                             -(4 * ONE_HOUR), st1.getOffset(time2));
+                             -(5 * ONE_HOUR), st1.getOffset(time2));
 
 		// test on subclass Support_TimeZone, an instance with daylight savings
 		TimeZone tz1 = new Support_TimeZone(-5 * ONE_HOUR, true);

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java Wed Jan 16 21:42:17 2008
@@ -22,7 +22,6 @@
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.Locale;
-import java.util.ResourceBundle;
 import java.util.TimeZone;
 
 import org.apache.harmony.text.internal.nls.Messages;
@@ -321,9 +320,8 @@
      */
     public final static DateFormat getDateInstance(int style, Locale locale) {
         checkDateStyle(style);
-        ResourceBundle bundle = getBundle(locale);
-        String pattern = bundle.getString("Date_" + getStyleName(style)); //$NON-NLS-1$
-        return new SimpleDateFormat(pattern, locale);
+        com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getDateInstance(style, locale);
+        return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
     }
 
     /**
@@ -370,10 +368,8 @@
             int timeStyle, Locale locale) {
         checkTimeStyle(timeStyle);
         checkDateStyle(dateStyle);
-        ResourceBundle bundle = getBundle(locale);
-        String pattern = bundle.getString("Date_" + getStyleName(dateStyle)) //$NON-NLS-1$
-                + " " + bundle.getString("Time_" + getStyleName(timeStyle)); //$NON-NLS-1$ //$NON-NLS-2$
-        return new SimpleDateFormat(pattern, locale);
+        com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
+        return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
     }
 
     /**
@@ -451,9 +447,8 @@
      */
     public final static DateFormat getTimeInstance(int style, Locale locale) {
         checkTimeStyle(style);
-        ResourceBundle bundle = getBundle(locale);
-        String pattern = bundle.getString("Time_" + getStyleName(style)); //$NON-NLS-1$
-        return new SimpleDateFormat(pattern, locale);
+        com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getTimeInstance(style, locale);
+        return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java Wed Jan 16 21:42:17 2008
@@ -20,7 +20,6 @@
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Locale;
-import java.util.ResourceBundle;
 
 /**
  * DateFormatSymbols holds the Strings used in the formating and parsing of
@@ -52,15 +51,16 @@
      *            the Locale
      */
     public DateFormatSymbols(Locale locale) {
-        ResourceBundle bundle = Format.getBundle(locale);
-        localPatternChars = bundle.getString("LocalPatternChars"); //$NON-NLS-1$
-        ampms = bundle.getStringArray("ampm"); //$NON-NLS-1$
-        eras = bundle.getStringArray("eras"); //$NON-NLS-1$
-        months = bundle.getStringArray("months"); //$NON-NLS-1$
-        shortMonths = bundle.getStringArray("shortMonths"); //$NON-NLS-1$
-        shortWeekdays = bundle.getStringArray("shortWeekdays"); //$NON-NLS-1$
-        weekdays = bundle.getStringArray("weekdays"); //$NON-NLS-1$
-        zoneStrings = (String[][]) bundle.getObject("timezones"); //$NON-NLS-1$
+        com.ibm.icu.text.DateFormatSymbols icuSymbols = new com.ibm.icu.text.DateFormatSymbols(locale);
+        
+        localPatternChars = icuSymbols.getLocalPatternChars();
+        ampms = icuSymbols.getAmPmStrings();
+        eras = icuSymbols.getEras();
+        months = icuSymbols.getMonths();
+        shortMonths = icuSymbols.getShortMonths();
+        shortWeekdays = icuSymbols.getShortWeekdays();
+        weekdays = icuSymbols.getWeekdays();
+        zoneStrings = icuSymbols.getZoneStrings();
     }
 
     /**
@@ -273,7 +273,9 @@
         }
         for (String[] element : zoneStrings) {
             for (int j = 0; j < element.length; j++) {
-                hashCode += element[j].hashCode();
+                if (element[j] != null) {
+                    hashCode += element[j].hashCode();
+                }
             }
         }
         return hashCode;

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java Wed Jan 16 21:42:17 2008
@@ -54,7 +54,15 @@
      * default Locale.
      */
     public DecimalFormat() {
-        this(getPattern(Locale.getDefault(), "Number")); //$NON-NLS-1$
+        Locale locale = Locale.getDefault();
+        icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
+        symbols = new DecimalFormatSymbols(locale);
+        dform = new com.ibm.icu.text.DecimalFormat();
+
+        super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+        super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+        super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+        super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
     }
 
     /**
@@ -68,7 +76,15 @@
      *                when the pattern cannot be parsed
      */
     public DecimalFormat(String pattern) {
-        this(pattern, new DecimalFormatSymbols());
+        Locale locale = Locale.getDefault();
+        icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
+        symbols = new DecimalFormatSymbols(locale);
+        dform = new com.ibm.icu.text.DecimalFormat(pattern, icuSymbols);
+
+        super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+        super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+        super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+        super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
     }
 
     /**
@@ -85,7 +101,7 @@
      */
     public DecimalFormat(String pattern, DecimalFormatSymbols value) {
         symbols = (DecimalFormatSymbols) value.clone();
-        Locale locale = (Locale) this.getInternalField("locale", symbols); //$NON-NLS-1$
+        Locale locale = symbols.getLocale(); //$NON-NLS-1$
         icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
         copySymbols(icuSymbols, symbols);
 
@@ -711,16 +727,16 @@
         fields.put("positiveSuffix", dform.getPositiveSuffix());
         fields.put("negativePrefix", dform.getNegativePrefix());
         fields.put("negativeSuffix", dform.getNegativeSuffix());
-        String posPrefixPattern = (String) this.getInternalField(
+        String posPrefixPattern = (String) Format.getInternalField(
                 "posPrefixPattern", dform);
         fields.put("posPrefixPattern", posPrefixPattern);
-        String posSuffixPattern = (String) this.getInternalField(
+        String posSuffixPattern = (String) Format.getInternalField(
                 "posSuffixPattern", dform);
         fields.put("posSuffixPattern", posSuffixPattern);
-        String negPrefixPattern = (String) this.getInternalField(
+        String negPrefixPattern = (String) Format.getInternalField(
                 "negPrefixPattern", dform);
         fields.put("negPrefixPattern", negPrefixPattern);
-        String negSuffixPattern = (String) this.getInternalField(
+        String negSuffixPattern = (String) Format.getInternalField(
                 "negSuffixPattern", dform);
         fields.put("negSuffixPattern", negSuffixPattern);
         fields.put("multiplier", dform.getMultiplier());
@@ -729,10 +745,10 @@
                 .isDecimalSeparatorAlwaysShown());
         fields.put("parseBigDecimal", parseBigDecimal);
         fields.put("symbols", symbols);
-        boolean useExponentialNotation = ((Boolean) this.getInternalField(
+        boolean useExponentialNotation = ((Boolean) Format.getInternalField(
                 "useExponentialNotation", dform)).booleanValue();
         fields.put("useExponentialNotation", useExponentialNotation);
-        byte minExponentDigits = ((Byte) this.getInternalField(
+        byte minExponentDigits = ((Byte) Format.getInternalField(
                 "minExponentDigits", dform)).byteValue();
         fields.put("minExponentDigits", minExponentDigits);
         fields.put("maximumIntegerDigits", dform.getMaximumIntegerDigits());
@@ -786,7 +802,7 @@
         int minimumFractionDigits = fields.get("minimumFractionDigits", 340);
         this.serialVersionOnStream = fields.get("serialVersionOnStream", 0);
 
-        Locale locale = (Locale) getInternalField("locale", symbols);
+        Locale locale = (Locale) Format.getInternalField("locale", symbols);
         dform = new com.ibm.icu.text.DecimalFormat("",
                 new com.ibm.icu.text.DecimalFormatSymbols(locale));
         setInternalField("useExponentialNotation", dform, Boolean
@@ -831,8 +847,14 @@
      */
     private void copySymbols(final com.ibm.icu.text.DecimalFormatSymbols icu,
             final DecimalFormatSymbols dfs) {
-        icu.setCurrency(com.ibm.icu.util.Currency.getInstance(dfs.getCurrency()
-                .getCurrencyCode()));
+        Currency currency = dfs.getCurrency();
+        if (currency == null) {
+            icu.setCurrency(com.ibm.icu.util.Currency.getInstance("XXX"));
+        } else {
+            icu.setCurrency(com.ibm.icu.util.Currency.getInstance(dfs
+                    .getCurrency().getCurrencyCode()));
+        }
+       
         icu.setCurrencySymbol(dfs.getCurrencySymbol());
         icu.setDecimalSeparator(dfs.getDecimalSeparator());
         icu.setDigit(dfs.getDigit());
@@ -874,31 +896,4 @@
                     }
                 });
     }
-
-    /*
-     * Gets private field value by reflection.
-     * 
-     * @param fieldName the field name to be set @param target the object which
-     * field to be gotten
-     */
-    private Object getInternalField(final String fieldName, final Object target) {
-        Object value = AccessController
-                .doPrivileged(new PrivilegedAction<Object>() {
-                    public Object run() {
-                        Object result = null;
-                        java.lang.reflect.Field field = null;
-                        try {
-                            field = target.getClass().getDeclaredField(
-                                    fieldName);
-                            field.setAccessible(true);
-                            result = field.get(target);
-                        } catch (Exception e1) {
-                            return null;
-                        }
-                        return result;
-                    }
-                });
-        return value;
-    }
-
 }

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java Wed Jan 16 21:42:17 2008
@@ -25,7 +25,6 @@
 import java.util.Arrays;
 import java.util.Currency;
 import java.util.Locale;
-import java.util.ResourceBundle;
 
 /**
  * DecimalFormatSymbols holds the symbols used in the formating and parsing of
@@ -64,20 +63,30 @@
      *            the Locale
      */
     public DecimalFormatSymbols(Locale locale) {
-        ResourceBundle bundle = Format.getBundle(locale);
-        patternChars = bundle.getString("DecimalPatternChars").toCharArray(); //$NON-NLS-1$
-        infinity = bundle.getString("Infinity"); //$NON-NLS-1$
-        NaN = bundle.getString("NaN"); //$NON-NLS-1$
+        com.ibm.icu.text.DecimalFormatSymbols icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(
+                locale);
+        infinity = icuSymbols.getInfinity();
+        NaN = icuSymbols.getNaN();
         this.locale = locale;
-        try {
+        currencySymbol = icuSymbols.getCurrencySymbol();
+        intlCurrencySymbol = icuSymbols.getInternationalCurrencySymbol();
+        if (locale.getCountry().length() == 0) {
+            currency = Currency.getInstance("XXX");
+        } else {
             currency = Currency.getInstance(locale);
-            currencySymbol = currency.getSymbol(locale);
-            intlCurrencySymbol = currency.getCurrencyCode();
-        } catch (IllegalArgumentException e) {
-            currency = Currency.getInstance("XXX"); //$NON-NLS-1$
-            currencySymbol = bundle.getString("CurrencySymbol"); //$NON-NLS-1$
-            intlCurrencySymbol = bundle.getString("IntCurrencySymbol"); //$NON-NLS-1$
         }
+        patternChars = new char[10];
+        patternChars[ZeroDigit] = icuSymbols.getZeroDigit();
+        patternChars[Digit] = icuSymbols.getDigit();
+        patternChars[DecimalSeparator] = icuSymbols.getDecimalSeparator();
+        patternChars[GroupingSeparator] = icuSymbols.getGroupingSeparator();
+        patternChars[PatternSeparator] = icuSymbols.getPatternSeparator();
+        patternChars[Percent] = icuSymbols.getPercent();
+        patternChars[PerMill] = icuSymbols.getPerMill();
+        patternChars[Exponent] = icuSymbols.getExponentSeparator().charAt(0);
+        patternChars[MonetaryDecimalSeparator] = icuSymbols.getMonetaryDecimalSeparator();
+        patternChars[MinusSign] = icuSymbols.getMinusSign();
+        
     }
 
     /**
@@ -539,5 +548,9 @@
         } catch (IllegalArgumentException e) {
             currency = null;
         }
+    }
+    
+    Locale getLocale(){
+        return locale;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java Wed Jan 16 21:42:17 2008
@@ -20,8 +20,6 @@
 import java.io.Serializable;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.util.Locale;
-import java.util.ResourceBundle;
 
 import org.apache.harmony.text.internal.nls.Messages;
 
@@ -56,17 +54,6 @@
         }
     }
 
-    static ResourceBundle getBundle(final Locale locale) {
-        return AccessController
-                .doPrivileged(new PrivilegedAction<ResourceBundle>() {
-                    public ResourceBundle run() {
-                        return ResourceBundle
-                                .getBundle(
-                                        "org.apache.harmony.luni.internal.locale.Locale", locale); //$NON-NLS-1$
-                    }
-                });
-    }
-
     String convertPattern(String template, String fromChars, String toChars,
             boolean check) {
         if (!check && fromChars.equals(toChars)) {
@@ -189,6 +176,32 @@
      * @return the object resulting from the parse, or null if there is an error
      */
     public abstract Object parseObject(String string, ParsePosition position);
+
+    /*
+     * Gets private field value by reflection.
+     * 
+     * @param fieldName the field name to be set @param target the object which
+     * field to be gotten
+     */
+    static Object getInternalField(final String fieldName, final Object target) {
+        Object value = AccessController
+                .doPrivileged(new PrivilegedAction<Object>() {
+                    public Object run() {
+                        Object result = null;
+                        java.lang.reflect.Field field = null;
+                        try {
+                            field = target.getClass().getDeclaredField(
+                                    fieldName);
+                            field.setAccessible(true);
+                            result = field.get(target);
+                        } catch (Exception e1) {
+                            return null;
+                        }
+                        return result;
+                    }
+                });
+        return value;
+    }
 
     static boolean upTo(String string, ParsePosition position,
             StringBuffer buffer, char stop) {

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java Wed Jan 16 21:42:17 2008
@@ -39,6 +39,8 @@
 
     private static final long serialVersionUID = 6479157306784022952L;
 
+    private static com.ibm.icu.text.MessageFormat format;
+
     private Locale locale = Locale.getDefault();
 
     transient private String[] strings;
@@ -444,7 +446,12 @@
      *                when the pattern cannot be parsed
      */
     public static String format(String template, Object... objects) {
-        return new MessageFormat(template).format(objects);
+        if (format == null) {
+            format = new com.ibm.icu.text.MessageFormat(template);
+        } else if (!template.equals(format.toPattern())){
+            format.applyPattern(template);
+        }
+        return format.format(objects);
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java?rev=612718&r1=612717&r2=612718&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java Wed Jan 16 21:42:17 2008
@@ -24,7 +24,6 @@
 import java.io.ObjectStreamField;
 import java.util.Currency;
 import java.util.Locale;
-import java.util.ResourceBundle;
 
 import org.apache.harmony.text.internal.nls.Messages;
 
@@ -230,7 +229,10 @@
      * @return a NumberFormat
      */
     public static NumberFormat getCurrencyInstance(Locale locale) {
-        return getInstance(locale, "Currency"); //$NON-NLS-1$
+        com.ibm.icu.text.DecimalFormat icuFormat = (com.ibm.icu.text.DecimalFormat) com.ibm.icu.text.NumberFormat
+                .getCurrencyInstance(locale);
+        String pattern = icuFormat.toPattern();
+        return new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
     }
 
     /**
@@ -252,9 +254,13 @@
      * @return a NumberFormat
      */
     public static NumberFormat getIntegerInstance(Locale locale) {
-        NumberFormat format = getInstance(locale, "Integer"); //$NON-NLS-1$
+        com.ibm.icu.text.DecimalFormat icuFormat = (com.ibm.icu.text.DecimalFormat) com.ibm.icu.text.NumberFormat
+                .getIntegerInstance(locale);
+        String pattern = icuFormat.toPattern();
+        DecimalFormat format = new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
         format.setParseIntegerOnly(true);
         return format;
+        
     }
 
     /**
@@ -279,11 +285,6 @@
         return getNumberInstance(locale);
     }
 
-    static NumberFormat getInstance(Locale locale, String type) {
-        return new DecimalFormat(getPattern(locale, type),
-                new DecimalFormatSymbols(locale));
-    }
-
     /**
      * Answers the maximum number of fraction digits that are printed when
      * formatting. If the maximum is less than the number of fraction digits,
@@ -345,12 +346,10 @@
      * @return a NumberFormat
      */
     public static NumberFormat getNumberInstance(Locale locale) {
-        return getInstance(locale, "Number"); //$NON-NLS-1$
-    }
-
-    static String getPattern(Locale locale, String type) {
-        ResourceBundle bundle = getBundle(locale);
-        return bundle.getString(type);
+        com.ibm.icu.text.DecimalFormat icuFormat = (com.ibm.icu.text.DecimalFormat) com.ibm.icu.text.NumberFormat
+                .getNumberInstance(locale);
+        String pattern = icuFormat.toPattern();
+        return new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
     }
 
     /**
@@ -372,7 +371,10 @@
      * @return a NumberFormat
      */
     public static NumberFormat getPercentInstance(Locale locale) {
-        return getInstance(locale, "Percent"); //$NON-NLS-1$
+        com.ibm.icu.text.DecimalFormat icuFormat = (com.ibm.icu.text.DecimalFormat) com.ibm.icu.text.NumberFormat
+                .getPercentInstance(locale);
+        String pattern = icuFormat.toPattern();
+        return new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
     }
 
     /**