diff --git a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormat.java b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormat.java index 14d0c9ab000..c83ca22b112 100644 --- a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormat.java +++ b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormat.java @@ -131,7 +131,10 @@ public class DateFormat extends Format { * work correctly unless they manipulate the delegate. */ protected DateFormat() { - this.dateFormat = java.text.DateFormat.getInstance(); + this.dateFormat = java.text.DateFormat.getDateTimeInstance( + java.text.DateFormat.SHORT, + java.text.DateFormat.SHORT, + ULocale.getDefault(Category.FORMAT).toLocale()); } /** @@ -897,7 +900,9 @@ public class DateFormat extends Format { */ public final static DateFormat getTimeInstance() { - return new DateFormat(java.text.DateFormat.getTimeInstance()); + return new DateFormat(java.text.DateFormat.getTimeInstance( + java.text.DateFormat.DEFAULT, + ULocale.getDefault(Category.FORMAT).toLocale())); } /** @@ -910,7 +915,9 @@ public class DateFormat extends Format { */ public final static DateFormat getTimeInstance(int style) { - return new DateFormat(java.text.DateFormat.getTimeInstance(getJDKFormatStyle(style))); + return new DateFormat(java.text.DateFormat.getTimeInstance( + getJDKFormatStyle(style), + ULocale.getDefault(Category.FORMAT).toLocale())); } /** @@ -951,7 +958,9 @@ public class DateFormat extends Format { */ public final static DateFormat getDateInstance() { - return new DateFormat(java.text.DateFormat.getDateInstance()); + return new DateFormat(java.text.DateFormat.getDateInstance( + java.text.DateFormat.DEFAULT, + ULocale.getDefault(Category.FORMAT).toLocale())); } /** @@ -964,7 +973,9 @@ public class DateFormat extends Format { */ public final static DateFormat getDateInstance(int style) { - return new DateFormat(java.text.DateFormat.getDateInstance(getJDKFormatStyle(style))); + return new DateFormat(java.text.DateFormat.getDateInstance( + getJDKFormatStyle(style), + ULocale.getDefault(Category.FORMAT).toLocale())); } /** @@ -1005,7 +1016,10 @@ public class DateFormat extends Format { */ public final static DateFormat getDateTimeInstance() { - return new DateFormat(java.text.DateFormat.getDateTimeInstance()); + return new DateFormat(java.text.DateFormat.getDateTimeInstance( + java.text.DateFormat.DEFAULT, + java.text.DateFormat.DEFAULT, + ULocale.getDefault(Category.FORMAT).toLocale())); } /** @@ -1023,13 +1037,20 @@ public class DateFormat extends Format { { if (dateStyle != NONE) { if (timeStyle != NONE) { - return new DateFormat(java.text.DateFormat.getDateTimeInstance(getJDKFormatStyle(dateStyle), getJDKFormatStyle(timeStyle))); + return new DateFormat(java.text.DateFormat.getDateTimeInstance( + getJDKFormatStyle(dateStyle), + getJDKFormatStyle(timeStyle), + ULocale.getDefault(Category.FORMAT).toLocale())); } else { - return new DateFormat(java.text.DateFormat.getDateInstance(getJDKFormatStyle(dateStyle))); + return new DateFormat(java.text.DateFormat.getDateInstance( + getJDKFormatStyle(dateStyle), + ULocale.getDefault(Category.FORMAT).toLocale())); } } if (timeStyle != NONE) { - return new DateFormat(java.text.DateFormat.getTimeInstance(getJDKFormatStyle(timeStyle))); + return new DateFormat(java.text.DateFormat.getTimeInstance( + getJDKFormatStyle(timeStyle), + ULocale.getDefault(Category.FORMAT).toLocale())); } return null; } @@ -1090,7 +1111,10 @@ public class DateFormat extends Format { * @stable ICU 2.0 */ public final static DateFormat getInstance() { - return new DateFormat(java.text.DateFormat.getInstance()); + return new DateFormat(java.text.DateFormat.getDateTimeInstance( + java.text.DateFormat.SHORT, + java.text.DateFormat.SHORT, + ULocale.getDefault(Category.FORMAT).toLocale())); } /** @@ -1434,7 +1458,7 @@ public class DateFormat extends Format { * @stable ICU 2.0 */ static final public DateFormat getTimeInstance(Calendar cal, int timeStyle) { - return getTimeInstance(cal, timeStyle, Locale.getDefault()); + return getTimeInstance(cal, timeStyle, ULocale.getDefault(Category.FORMAT)); } /** diff --git a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormatSymbols.java b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormatSymbols.java index 2cff97c65cc..a73dc199110 100644 --- a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormatSymbols.java +++ b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormatSymbols.java @@ -16,6 +16,7 @@ import java.util.ResourceBundle; import com.ibm.icu.util.Calendar; import com.ibm.icu.util.ULocale; +import com.ibm.icu.util.ULocale.Category; /** * {@icuenhanced java.text.DateFormatSymbols}.{@icu _usage_} @@ -135,7 +136,7 @@ public class DateFormatSymbols implements Serializable, Cloneable { */ public DateFormatSymbols() { - this(new java.text.DateFormatSymbols()); + this(new java.text.DateFormatSymbols(ULocale.getDefault(Category.FORMAT).toLocale())); } /** @@ -176,7 +177,7 @@ public class DateFormatSymbols implements Serializable, Cloneable { * @stable ICU 3.8 */ public static DateFormatSymbols getInstance() { - return new DateFormatSymbols(new java.text.DateFormatSymbols()); + return new DateFormatSymbols(); } /** diff --git a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormat.java b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormat.java index 14eea149402..c440fa2ad54 100644 --- a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormat.java +++ b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormat.java @@ -13,6 +13,7 @@ import java.text.AttributedString; import java.text.CharacterIterator; import java.text.FieldPosition; import java.text.ParsePosition; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; @@ -20,6 +21,8 @@ import com.ibm.icu.math.BigDecimal; import com.ibm.icu.math.MathContext; import com.ibm.icu.util.Currency; import com.ibm.icu.util.CurrencyAmount; +import com.ibm.icu.util.ULocale; +import com.ibm.icu.util.ULocale.Category; /** * {@icuenhanced java.text.DecimalFormat}.{@icu _usage_} @@ -613,7 +616,19 @@ public class DecimalFormat extends NumberFormat { * @stable ICU 2.0 */ public DecimalFormat() { + // There is no way to construct java.text.DecimalFormat with an + // explicit Locale. this(new java.text.DecimalFormat()); + + if (!ULocale.getDefault(Category.FORMAT).toLocale().equals(Locale.getDefault())) { + // On Java 6 or older JRE, ULocale's FORMAT default might be different + // from the locale used for constructing java.text.DecimalFormat + java.text.NumberFormat jdkNfmt = java.text.NumberFormat.getInstance(ULocale.getDefault(Category.FORMAT).toLocale()); + if (jdkNfmt instanceof java.text.DecimalFormat) { + ((java.text.DecimalFormat)numberFormat).applyPattern(((java.text.DecimalFormat)jdkNfmt).toPattern()); + ((java.text.DecimalFormat)numberFormat).setDecimalFormatSymbols(((java.text.DecimalFormat)jdkNfmt).getDecimalFormatSymbols()); + } + } } /** @@ -634,7 +649,9 @@ public class DecimalFormat extends NumberFormat { * @stable ICU 2.0 */ public DecimalFormat(String pattern) { - this(new java.text.DecimalFormat(pattern)); + this(new java.text.DecimalFormat( + pattern, + new java.text.DecimalFormatSymbols(ULocale.getDefault(Category.FORMAT).toLocale()))); } /** diff --git a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormatSymbols.java b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormatSymbols.java index 51fc72ac54d..db03cd0bdc3 100644 --- a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormatSymbols.java +++ b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormatSymbols.java @@ -12,6 +12,7 @@ import java.io.Serializable; import java.util.Locale; import com.ibm.icu.util.ULocale; +import com.ibm.icu.util.ULocale.Category; /** * This class represents the set of symbols (such as the decimal separator, the @@ -54,7 +55,7 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable { * @stable ICU 2.0 */ public DecimalFormatSymbols() { - this(new java.text.DecimalFormatSymbols()); + this(new java.text.DecimalFormatSymbols(ULocale.getDefault(Category.FORMAT).toLocale())); } /** diff --git a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/MessageFormat.java b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/MessageFormat.java index 31c27132836..4af68238336 100644 --- a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/MessageFormat.java +++ b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/MessageFormat.java @@ -26,6 +26,7 @@ import java.util.Map.Entry; import java.util.Set; import com.ibm.icu.util.ULocale; +import com.ibm.icu.util.ULocale.Category; /** * {@icuenhanced java.text.MessageFormat}.{@icu _usage_} @@ -437,7 +438,7 @@ public class MessageFormat extends UFormat { * @stable ICU 3.0 */ public MessageFormat(String pattern) { - this(new java.text.MessageFormat(pattern)); + this(new java.text.MessageFormat(pattern, ULocale.getDefault(Category.FORMAT).toLocale())); } /** diff --git a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/NumberFormat.java b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/NumberFormat.java index 831e146198d..bc23e4a7e15 100644 --- a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/NumberFormat.java +++ b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/NumberFormat.java @@ -1137,13 +1137,13 @@ public class NumberFormat extends Format { } /** - * Empty constructor. Public for compatibily with JDK which lets the + * Empty constructor. Public for compatibility with JDK which lets the * compiler generate a default public constructor even though this is * an abstract class. * @stable ICU 2.6 */ public NumberFormat() { - this(java.text.NumberFormat.getInstance()); + this(java.text.NumberFormat.getInstance(ULocale.getDefault(Category.FORMAT).toLocale())); } /** diff --git a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Calendar.java b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Calendar.java index d7b4730749f..5686ccfbd90 100644 --- a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Calendar.java +++ b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Calendar.java @@ -1172,7 +1172,7 @@ public class Calendar implements Serializable, Cloneable, Comparable { */ public static synchronized Calendar getInstance() { - return new Calendar(java.util.Calendar.getInstance()); + return new Calendar(java.util.Calendar.getInstance(ULocale.getDefault(Category.FORMAT).toLocale())); } /** @@ -1183,7 +1183,7 @@ public class Calendar implements Serializable, Cloneable, Comparable { */ public static synchronized Calendar getInstance(TimeZone zone) { - return new Calendar(java.util.Calendar.getInstance(zone.timeZone)); + return new Calendar(java.util.Calendar.getInstance(zone.timeZone, ULocale.getDefault(Category.FORMAT).toLocale())); } /** diff --git a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Currency.java b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Currency.java index d6350290174..1d01024eb69 100644 --- a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Currency.java +++ b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Currency.java @@ -11,6 +11,8 @@ import java.text.ParsePosition; import java.util.Date; import java.util.Locale; +import com.ibm.icu.util.ULocale.Category; + /** * A class encapsulating a currency, as defined by ISO 4217. A * Currency object can be created given a Locale or @@ -230,7 +232,7 @@ public class Currency implements Serializable { * @stable ICU 3.4 */ public String getSymbol() { - return currency.getSymbol(); + return currency.getSymbol(ULocale.getDefault(Category.DISPLAY).toLocale()); } /** diff --git a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/TimeZone.java b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/TimeZone.java index 0e35274753d..5ff5732fcb3 100644 --- a/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/TimeZone.java +++ b/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/TimeZone.java @@ -322,7 +322,7 @@ public class TimeZone implements Serializable, Cloneable { * @stable ICU 2.0 */ public final String getDisplayName() { - return timeZone.getDisplayName(); + return timeZone.getDisplayName(ULocale.getDefault(Category.DISPLAY).toLocale()); } /**