import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
import com.ibm.icu.util.VersionInfo;
+import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.text.Collator}.{@icu _usage_}
/**
* {@icu} Returns the name of the collator for the objectLocale, localized for the
- * current locale.
+ * default <code>DISPLAY</code> locale.
* @param objectLocale the locale of the collator
* @return the display name
+ * @see com.ibm.icu.util.ULocale.Category#DISPLAY
* @stable ICU 2.6
*/
static public String getDisplayName(Locale objectLocale) {
- return getShim().getDisplayName(ULocale.forLocale(objectLocale), ULocale.getDefault());
+ return getShim().getDisplayName(ULocale.forLocale(objectLocale), ULocale.getDefault(Category.DISPLAY));
}
/**
* {@icu} Returns the name of the collator for the objectLocale, localized for the
- * current locale.
+ * default <code>DISPLAY</code> locale.
* @param objectLocale the locale of the collator
* @return the display name
+ * @see com.ibm.icu.util.ULocale.Category#DISPLAY
* @stable ICU 3.2
*/
static public String getDisplayName(ULocale objectLocale) {
- return getShim().getDisplayName(objectLocale, ULocale.getDefault());
+ return getShim().getDisplayName(objectLocale, ULocale.getDefault(Category.DISPLAY));
}
/**
/**
*******************************************************************************
- * Copyright (C) 2001-2010, International Business Machines Corporation and *
+ * Copyright (C) 2001-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
import java.util.TreeMap;
import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.ULocale.Category;
/**
* <p>A Service provides access to service objects that implement a
* uses the current default locale.
*/
public String getDisplayName(String id) {
- return getDisplayName(id, ULocale.getDefault());
+ return getDisplayName(id, ULocale.getDefault(Category.DISPLAY));
}
/**
* the comparator, and null for the matchID.
*/
public SortedMap<String, String> getDisplayNames() {
- ULocale locale = ULocale.getDefault();
+ ULocale locale = ULocale.getDefault(Category.DISPLAY);
return getDisplayNames(locale, null, null);
}
/****************************************************************************
- * Copyright (C) 2000-2010, International Business Machines Corporation and
+ * Copyright (C) 2000-2011, International Business Machines Corporation and
* others. All Rights Reserved.
****************************************************************************
*/
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.ChineseCalendar;
import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.ULocale.Category;
/**
* A subclass of {@link DateFormatSymbols} for {@link ChineseDateFormat}.
String isLeapMonth[]; // Do NOT add =null initializer
/**
- * Construct a ChineseDateFormatSymbols for the default locale.
+ * Construct a ChineseDateFormatSymbols for the default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public ChineseDateFormatSymbols() {
- this(ULocale.getDefault());
+ this(ULocale.getDefault(Category.FORMAT));
}
/**
/*
*******************************************************************************
- * Copyright (C) 2009-2010, International Business Machines Corporation and *
+ * Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
import com.ibm.icu.impl.CurrencyData;
import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.ULocale.Category;
/**
* This class represents the information needed by
private static final long serialVersionUID = 1;
/**
- * Create a CurrencyPluralInfo object for the default locale.
+ * Create a CurrencyPluralInfo object for the default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 4.2
*/
public CurrencyPluralInfo() {
- initialize(ULocale.getDefault());
+ initialize(ULocale.getDefault(Category.FORMAT));
}
/**
import com.ibm.icu.util.GregorianCalendar;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.text.DateFormat}.{@icu _usage_}
/**
* Gets the time formatter with the default formatting style
- * for the default locale.
+ * for the default <code>FORMAT</code> locale.
* @return a time formatter.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static DateFormat getTimeInstance()
{
- return get(-1, DEFAULT, ULocale.getDefault());
+ return get(-1, DEFAULT, ULocale.getDefault(Category.FORMAT));
}
/**
* Returns the time formatter with the given formatting style
- * for the default locale.
+ * for the default <code>FORMAT</code> locale.
* @param style the given formatting style. For example,
* SHORT for "h:mm a" in the US locale.
* @return a time formatter.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static DateFormat getTimeInstance(int style)
{
- return get(-1, style, ULocale.getDefault());
+ return get(-1, style, ULocale.getDefault(Category.FORMAT));
}
/**
/**
* Returns the date formatter with the default formatting style
- * for the default locale.
+ * for the default <code>FORMAT</code> locale.
* @return a date formatter.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static DateFormat getDateInstance()
{
- return get(DEFAULT, -1, ULocale.getDefault());
+ return get(DEFAULT, -1, ULocale.getDefault(Category.FORMAT));
}
/**
* Returns the date formatter with the given formatting style
- * for the default locale.
+ * for the default <code>FORMAT</code> locale.
* @param style the given formatting style. For example,
* SHORT for "M/d/yy" in the US locale.
* @return a date formatter.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static DateFormat getDateInstance(int style)
{
- return get(style, -1, ULocale.getDefault());
+ return get(style, -1, ULocale.getDefault(Category.FORMAT));
}
/**
/**
* Returns the date/time formatter with the default formatting style
- * for the default locale.
+ * for the default <code>FORMAT</code> locale.
* @return a date/time formatter.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static DateFormat getDateTimeInstance()
{
- return get(DEFAULT, DEFAULT, ULocale.getDefault());
+ return get(DEFAULT, DEFAULT, ULocale.getDefault(Category.FORMAT));
}
/**
* Returns the date/time formatter with the given date and time
- * formatting styles for the default locale.
+ * formatting styles for the default <code>FORMAT</code> locale.
* @param dateStyle the given date formatting style. For example,
* SHORT for "M/d/yy" in the US locale.
* @param timeStyle the given time formatting style. For example,
* SHORT for "h:mm a" in the US locale.
* @return a date/time formatter.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static DateFormat getDateTimeInstance(int dateStyle,
int timeStyle)
{
- return get(dateStyle, timeStyle, ULocale.getDefault());
+ return get(dateStyle, timeStyle, ULocale.getDefault(Category.FORMAT));
}
/**
* @stable ICU 2.0
*/
static final public DateFormat getInstance(Calendar cal) {
- return getInstance(cal, ULocale.getDefault());
+ return getInstance(cal, ULocale.getDefault(Category.FORMAT));
}
/**
* @stable ICU 2.0
*/
static final public DateFormat getDateInstance(Calendar cal, int dateStyle) {
- return getDateInstance(cal, dateStyle, ULocale.getDefault());
+ return getDateInstance(cal, dateStyle, ULocale.getDefault(Category.FORMAT));
}
/**
* @stable ICU 2.0
*/
static final public DateFormat getTimeInstance(Calendar cal, int timeStyle) {
- return getTimeInstance(cal, timeStyle, ULocale.getDefault());
+ return getTimeInstance(cal, timeStyle, ULocale.getDefault(Category.FORMAT));
}
/**
* @stable ICU 2.0
*/
static final public DateFormat getDateTimeInstance(Calendar cal, int dateStyle, int timeStyle) {
- return getDateTimeInstance(cal, dateStyle, timeStyle, ULocale.getDefault());
+ return getDateTimeInstance(cal, dateStyle, timeStyle, ULocale.getDefault(Category.FORMAT));
}
/**
* @stable ICU 4.0
*/
public final static DateFormat getPatternInstance(String pattern) {
- return getPatternInstance(pattern, ULocale.getDefault());
+ return getPatternInstance(pattern, ULocale.getDefault(Category.FORMAT));
}
/**
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
+import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.text.DateFormatSymbols}.{@icu _usage_}
/**
* Constructs a DateFormatSymbols object by loading format data from
- * resources for the default locale.
+ * resources for the default <code>FORMAT</code> locale.
*
* @throws java.util.MissingResourceException if the resources for the default locale
* cannot be found or cannot be loaded.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public DateFormatSymbols()
{
- this(ULocale.getDefault());
+ this(ULocale.getDefault(Category.FORMAT));
}
/**
/*
-* Copyright (C) 2008-2010, International Business Machines
+* Copyright (C) 2008-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*/
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.DateInterval;
import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.ULocale.Category;
/**
/**
- * Construct a DateIntervalFormat from skeleton and the default locale.
+ * Construct a DateIntervalFormat from skeleton and the default <code>FORMAT</code> locale.
*
* This is a convenient override of
* getInstance(String skeleton, ULocale locale)
- * with the value of locale as default locale.
+ * with the value of locale as default <code>FORMAT</code> locale.
*
* @param skeleton the skeleton on which interval format based.
* @return a date time interval formatter.
+ * @see Category#FORMAT
* @stable ICU 4.0
*/
public static final DateIntervalFormat
getInstance(String skeleton)
{
- return getInstance(skeleton, ULocale.getDefault());
+ return getInstance(skeleton, ULocale.getDefault(Category.FORMAT));
}
/**
* Construct a DateIntervalFormat from skeleton
- * DateIntervalInfo, and default locale.
+ * DateIntervalInfo, and the default <code>FORMAT</code> locale.
*
* This is a convenient override of
* getInstance(String skeleton, ULocale locale, DateIntervalInfo dtitvinf)
- * with the locale value as default locale.
+ * with the locale value as default <code>FORMAT</code> locale.
*
* @param skeleton the skeleton on which interval format based.
* @param dtitvinf the DateIntervalInfo object to be adopted.
* @return a date time interval formatter.
+ * @see Category#FORMAT
* @stable ICU 4.0
*/
public static final DateIntervalFormat getInstance(String skeleton,
DateIntervalInfo dtitvinf)
{
- return getInstance(skeleton, ULocale.getDefault(), dtitvinf);
+ return getInstance(skeleton, ULocale.getDefault(Category.FORMAT), dtitvinf);
}
import com.ibm.icu.util.Freezable;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
+import com.ibm.icu.util.ULocale.Category;
/**
* This class provides flexible generation of date format patterns, like
}
/**
- * Construct a flexible generator according to data for the default locale.
+ * Construct a flexible generator according to data for the default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 3.6
*/
public static DateTimePatternGenerator getInstance() {
- return getInstance(ULocale.getDefault());
+ return getInstance(ULocale.getDefault(Category.FORMAT));
}
/**
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_}
/**
* Creates a DecimalFormat using the default pattern and symbols for the default
- * locale. This is a convenient way to obtain a DecimalFormat when
+ * <code>FORMAT</code> locale. This is a convenient way to obtain a DecimalFormat when
* internationalization is not the main concern.
*
* <p>To obtain standard formats for a given locale, use the factory methods on
* @see NumberFormat#getNumberInstance
* @see NumberFormat#getCurrencyInstance
* @see NumberFormat#getPercentInstance
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public DecimalFormat() {
- ULocale def = ULocale.getDefault();
+ ULocale def = ULocale.getDefault(Category.FORMAT);
String pattern = getPattern(def, 0);
// Always applyPattern after the symbols are set
this.symbols = new DecimalFormatSymbols(def);
/**
* Creates a DecimalFormat from the given pattern and the symbols for the default
- * locale. This is a convenient way to obtain a DecimalFormat when
+ * <code>FORMAT</code> locale. This is a convenient way to obtain a DecimalFormat when
* internationalization is not the main concern.
*
* <p>To obtain standard formats for a given locale, use the factory methods on
* @see NumberFormat#getNumberInstance
* @see NumberFormat#getCurrencyInstance
* @see NumberFormat#getPercentInstance
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public DecimalFormat(String pattern) {
// Always applyPattern after the symbols are set
- ULocale def = ULocale.getDefault();
+ ULocale def = ULocale.getDefault(Category.FORMAT);
this.symbols = new DecimalFormatSymbols(def);
setCurrency(Currency.getInstance(def));
applyPatternWithoutExpandAffix(pattern, false);
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
+import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.text.DecimalFormatSymbols}.{@icu _usage_}
*/
public class DecimalFormatSymbols implements Cloneable, Serializable {
/**
- * Creates a DecimalFormatSymbols object for the default locale.
+ * Creates a DecimalFormatSymbols object for the default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public DecimalFormatSymbols() {
- initialize(ULocale.getDefault());
+ initialize(ULocale.getDefault(Category.FORMAT));
}
/**
/*
**********************************************************************
-* Copyright (c) 2004-2007, International Business Machines
+* Copyright (c) 2004-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
package com.ibm.icu.text;
import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.ULocale.Category;
/**
* A formatter for Measure objects. This is an abstract base class.
/**
* Return a formatter for CurrencyAmount objects in the default
- * locale.
+ * <code>FORMAT</code> locale.
* @return a formatter object
+ * @see Category#FORMAT
* @stable ICU 3.0
*/
public static MeasureFormat getCurrencyFormat() {
- return getCurrencyFormat(ULocale.getDefault());
+ return getCurrencyFormat(ULocale.getDefault(Category.FORMAT));
}
}
import com.ibm.icu.text.MessagePattern.ArgType;
import com.ibm.icu.text.MessagePattern.Part;
import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.text.MessageFormat}.{@icu _usage_}
static final long serialVersionUID = 7136212545847378652L;
/**
- * Constructs a MessageFormat for the default locale and the
+ * Constructs a MessageFormat for the default <code>FORMAT</code> locale and the
* specified pattern.
* Sets the locale and calls applyPattern(pattern).
*
* @param pattern the pattern for this message format
* @exception IllegalArgumentException if the pattern is invalid
+ * @see Category#FORMAT
* @stable ICU 3.0
*/
public MessageFormat(String pattern) {
- this.ulocale = ULocale.getDefault();
+ this.ulocale = ULocale.getDefault(Category.FORMAT);
applyPattern(pattern);
}
import com.ibm.icu.util.CurrencyAmount;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
+import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.text.NumberFormat}.{@icu _usage_}
//============== Locale Stuff =====================
/**
- * Returns the default number format for the current default locale.
+ * Returns the default number format for the current default <code>FORMAT</code> locale.
* The default format is one of the styles provided by the other
* factory methods: getNumberInstance, getIntegerInstance,
* getCurrencyInstance or getPercentInstance.
* Exactly which one is locale-dependent.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
//Bug 4408066 [Richard/GCL]
public final static NumberFormat getInstance() {
- return getInstance(ULocale.getDefault(), NUMBERSTYLE);
+ return getInstance(ULocale.getDefault(Category.FORMAT), NUMBERSTYLE);
}
/**
}
/**
- * {@icu} Returns a specific style number format for default locale.
+ * {@icu} Returns a specific style number format for default <code>FORMAT</code> locale.
* @param style number format style
+ * @see Category#FORMAT
* @stable ICU 4.2
*/
public final static NumberFormat getInstance(int style) {
- return getInstance(ULocale.getDefault(), style);
+ return getInstance(ULocale.getDefault(Category.FORMAT), style);
}
/**
/**
- * Returns a general-purpose number format for the current default locale.
+ * Returns a general-purpose number format for the current default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static NumberFormat getNumberInstance() {
- return getInstance(ULocale.getDefault(), NUMBERSTYLE);
+ return getInstance(ULocale.getDefault(Category.FORMAT), NUMBERSTYLE);
}
/**
}
/**
- * Returns an integer number format for the current default locale. The
+ * Returns an integer number format for the current default <code>FORMAT</code> locale. The
* returned number format is configured to round floating point numbers
* to the nearest integer using IEEE half-even rounding (see {@link
* com.ibm.icu.math.BigDecimal#ROUND_HALF_EVEN ROUND_HALF_EVEN}) for formatting,
* #isParseIntegerOnly isParseIntegerOnly}).
*
* @return a number format for integer values
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
//Bug 4408066 [Richard/GCL]
public final static NumberFormat getIntegerInstance() {
- return getInstance(ULocale.getDefault(), INTEGERSTYLE);
+ return getInstance(ULocale.getDefault(Category.FORMAT), INTEGERSTYLE);
}
/**
}
/**
- * Returns a currency format for the current default locale.
+ * Returns a currency format for the current default <code>FORMAT</code> locale.
* @return a number format for currency
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static NumberFormat getCurrencyInstance() {
- return getInstance(ULocale.getDefault(), CURRENCYSTYLE);
+ return getInstance(ULocale.getDefault(Category.FORMAT), CURRENCYSTYLE);
}
/**
}
/**
- * Returns a percentage format for the current default locale.
+ * Returns a percentage format for the current default <code>FORMAT</code> locale.
* @return a number format for percents
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static NumberFormat getPercentInstance() {
- return getInstance(ULocale.getDefault(), PERCENTSTYLE);
+ return getInstance(ULocale.getDefault(Category.FORMAT), PERCENTSTYLE);
}
/**
}
/**
- * {@icu} Returns a scientific format for the current default locale.
+ * {@icu} Returns a scientific format for the current default <code>FORMAT</code> locale.
* @return a scientific number format
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public final static NumberFormat getScientificInstance() {
- return getInstance(ULocale.getDefault(), SCIENTIFICSTYLE);
+ return getInstance(ULocale.getDefault(Category.FORMAT), SCIENTIFICSTYLE);
}
/**
if (c == null) {
ULocale uloc = getLocale(ULocale.VALID_LOCALE);
if (uloc == null) {
- uloc = ULocale.getDefault();
+ uloc = ULocale.getDefault(Category.FORMAT);
}
c = Currency.getInstance(uloc);
}
/*
*******************************************************************************
- * Copyright (C) 2009-2010, International Business Machines Corporation and *
+ * Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
import com.ibm.icu.util.UResourceBundleIterator;
+import com.ibm.icu.util.ULocale.Category;
/**
}
/**
- * Returns the default numbering system for the default locale.
+ * Returns the default numbering system for the default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 4.2
*/
public static NumberingSystem getInstance() {
- return getInstance(ULocale.getDefault());
+ return getInstance(ULocale.getDefault(Category.FORMAT));
}
/**
import com.ibm.icu.impl.Utility;
import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.ULocale.Category;
/**
* <p>
* @stable ICU 3.8
*/
public PluralFormat() {
- init(null, ULocale.getDefault());
+ init(null, ULocale.getDefault(Category.FORMAT));
}
/**
* @stable ICU 3.8
*/
public PluralFormat(PluralRules rules) {
- init(rules, ULocale.getDefault());
+ init(rules, ULocale.getDefault(Category.FORMAT));
}
/**
* @stable ICU 3.8
*/
public PluralFormat(String pattern) {
- init(null, ULocale.getDefault());
+ init(null, ULocale.getDefault(Category.FORMAT));
applyPattern(pattern);
}
* @stable ICU 3.8
*/
public PluralFormat(PluralRules rules, String pattern) {
- init(rules, ULocale.getDefault());
+ init(rules, ULocale.getDefault(Category.FORMAT));
applyPattern(pattern);
}
* constructed from {@link #PluralFormat(ULocale)}.
* @param ulocale the <code>ULocale</code> used to configure the
* formatter. If <code>ulocale</code> is <code>null</code>, the
- * default locale will be used.
+ * default <code>FORMAT</code> locale will be used.
+ * @see Category#FORMAT
* @stable ICU 3.8
*/
public void setLocale(ULocale ulocale) {
if (ulocale == null) {
- ulocale = ULocale.getDefault();
+ ulocale = ULocale.getDefault(Category.FORMAT);
}
init(null, ulocale);
}
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
import com.ibm.icu.util.UResourceBundleIterator;
+import com.ibm.icu.util.ULocale.Category;
/**
/**
* Creates a RuleBasedNumberFormat that behaves according to the description
- * passed in. The formatter uses the default locale.
+ * passed in. The formatter uses the default <code>FORMAT</code> locale.
* @param description A description of the formatter's desired behavior.
* See the class documentation for a complete explanation of the description
* syntax.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public RuleBasedNumberFormat(String description) {
- locale = ULocale.getDefault();
+ locale = ULocale.getDefault(Category.FORMAT);
init(description, null);
}
/**
* Creates a RuleBasedNumberFormat that behaves according to the description
- * passed in. The formatter uses the default locale.
+ * passed in. The formatter uses the default <code>FORMAT</code> locale.
* <p>
* The localizations data provides information about the public
* rule sets and their localized display names for different
* syntax.
* @param localizations a list of localizations for the rule set
* names in the description.
+ * @see Category#FORMAT
* @stable ICU 3.2
*/
public RuleBasedNumberFormat(String description, String[][] localizations) {
- locale = ULocale.getDefault();
+ locale = ULocale.getDefault(Category.FORMAT);
init(description, localizations);
}
/**
* Creates a RuleBasedNumberFormat from a predefined description. Uses the
- * default locale.
+ * default <code>FORMAT</code> locale.
* @param format A selector code specifying which kind of formatter to create.
* There are three legal values: SPELLOUT, which creates a formatter that spells
* out a value in words in the default locale's langyage, ORDINAL, which attaches
* an ordinal suffix from the default locale's language to a numeral, and
* DURATION, which formats a duration in seconds as hours, minutes, and seconds.
* or NUMBERING_SYSTEM, which is used for alternate numbering systems such as Hebrew.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public RuleBasedNumberFormat(int format) {
- this(ULocale.getDefault(), format);
+ this(ULocale.getDefault(Category.FORMAT), format);
}
//-----------------------------------------------------------------------
try {
loc = (ULocale) in.readObject();
} catch (Exception e) {
- loc = ULocale.getDefault();
+ loc = ULocale.getDefault(Category.FORMAT);
}
// build a brand-new RuleBasedNumberFormat from the description,
private String[] getNameListForLocale(ULocale loc) {
if (loc != null && ruleSetDisplayNames != null) {
- String[] localeNames = { loc.getBaseName(), ULocale.getDefault().getBaseName() };
+ String[] localeNames = { loc.getBaseName(), ULocale.getDefault(Category.DISPLAY).getBaseName() };
for (int i = 0; i < localeNames.length; ++i) {
String lname = localeNames[i];
while (lname.length() > 0) {
}
/**
- * Return the rule set display names for the current default locale.
+ * Return the rule set display names for the current default <code>DISPLAY</code> locale.
* @return an array of the display names
* @see #getRuleSetDisplayNames(ULocale)
+ * @see Category#DISPLAY
* @stable ICU 3.2
*/
public String[] getRuleSetDisplayNames() {
- return getRuleSetDisplayNames(ULocale.getDefault());
+ return getRuleSetDisplayNames(ULocale.getDefault(Category.DISPLAY));
}
/**
}
/**
- * Return the rule set display name for the provided rule set in the current default locale.
+ * Return the rule set display name for the provided rule set in the current default <code>DISPLAY</code> locale.
* @return the display name for the rule set
* @see #getRuleSetDisplayName(String,ULocale)
+ * @see Category#DISPLAY
* @stable ICU 3.2
*/
public String getRuleSetDisplayName(String ruleSetName) {
- return getRuleSetDisplayName(ruleSetName, ULocale.getDefault());
+ return getRuleSetDisplayName(ruleSetName, ULocale.getDefault(Category.DISPLAY));
}
/**
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.TimeZoneTransition;
import com.ibm.icu.util.ULocale;
+import com.ibm.icu.util.ULocale.Category;
/**
private volatile TimeZoneFormat tzFormat;
/**
- * Constructs a SimpleDateFormat using the default pattern for the default
+ * Constructs a SimpleDateFormat using the default pattern for the default <code>FORMAT</code>
* locale. <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
*
* @see DateFormat
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public SimpleDateFormat() {
}
/**
- * Constructs a SimpleDateFormat using the given pattern in the default
+ * Constructs a SimpleDateFormat using the given pattern in the default <code>FORMAT</code>
* locale. <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public SimpleDateFormat(String pattern)
/**
* Constructs a SimpleDateFormat using the given pattern and
* locale-specific symbol data.
- * Warning: uses default locale for digits!
+ * Warning: uses default <code>FORMAT</code> locale for digits!
* @stable ICU 2.0
*/
public SimpleDateFormat(String pattern, DateFormatSymbols formatData)
*/
private void initialize() {
if (locale == null) {
- locale = ULocale.getDefault();
+ locale = ULocale.getDefault(Category.FORMAT);
}
if (formatData == null) {
formatData = new DateFormatSymbols(locale);
* This method is only used by the default SimpleDateFormat constructor.
*/
private static synchronized String getDefaultPattern() {
- ULocale defaultLocale = ULocale.getDefault();
+ ULocale defaultLocale = ULocale.getDefault(Category.FORMAT);
if (!defaultLocale.equals(cachedDefaultLocale)) {
cachedDefaultLocale = defaultLocale;
Calendar cal = Calendar.getInstance(cachedDefaultLocale);
// ICU4J 3.6 or older versions did not have UFormat locales
// in the serialized data. This is just for preventing the
// worst case scenario...
- locale = ULocale.getDefault();
+ locale = ULocale.getDefault(Category.FORMAT);
}
initLocalZeroPaddingNumberFormat();
/*
**************************************************************************
- * Copyright (C) 2008-2010, Google, International Business Machines
+ * Copyright (C) 2008-2011, Google, International Business Machines
* Corporationand others. All Rights Reserved.
**************************************************************************
*/
import com.ibm.icu.util.TimeUnitAmount;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
+import com.ibm.icu.util.ULocale.Category;
/**
if (format != null) {
locale = format.getLocale(null);
} else {
- locale = ULocale.getDefault();
+ locale = ULocale.getDefault(Category.FORMAT);
}
}
if (format == null) {
/*
*******************************************************************************
- * Copyright (C) 2005-2010, International Business Machines Corporation and *
+ * Copyright (C) 2005-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
import java.util.Date;
import java.util.Locale;
+import com.ibm.icu.util.ULocale.Category;
+
/**
* Base class for EthiopicCalendar and CopticCalendar.
*/
/**
* Constructs a default <code>CECalendar</code> using the current time
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*/
protected CECalendar() {
- this(TimeZone.getDefault(), ULocale.getDefault());
+ this(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
}
/**
* Constructs a <code>CECalendar</code> based on the current time
- * in the given time zone with the default locale.
+ * in the given time zone with the default <code>FORMAT</code> locale.
*
* @param zone The time zone for the new calendar.
*/
protected CECalendar(TimeZone zone) {
- this(zone, ULocale.getDefault());
+ this(zone, ULocale.getDefault(Category.FORMAT));
}
/**
/**
* Constructs a <code>CECalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
*
* @param date The value used to set the calendar's {@link #DATE DATE} time field.
*/
protected CECalendar(int year, int month, int date) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.set(year, month, date);
}
/**
* Constructs a <code>CECalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param date The date to which the new calendar is set.
*/
protected CECalendar(Date date) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.setTime(date);
}
/**
* Constructs a <code>CECalendar</code> with the given date
- * and time set for the default time zone with the default locale.
+ * and time set for the default time zone with the default <code>FORMAT</code> locale.
*
* @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
* @param month The value used to set the calendar's {@link #MONTH MONTH} time field.
protected CECalendar(int year, int month, int date, int hour,
int minute, int second)
{
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.set(year, month, date, hour, minute, second);
}
import com.ibm.icu.text.DateFormatSymbols;
import com.ibm.icu.text.MessageFormat;
import com.ibm.icu.text.SimpleDateFormat;
+import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.util.Calendar}.{@icu _usage_}
/**
* Constructs a Calendar with the default time zone
- * and locale.
+ * and the default <code>FORMAT</code> locale.
* @see TimeZone#getDefault
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
protected Calendar()
{
- this(TimeZone.getDefault(), ULocale.getDefault());
+ this(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
}
/**
*/
private static Calendar getInstanceInternal(TimeZone tz, ULocale locale) {
if (locale == null) {
- locale = ULocale.getDefault();
+ locale = ULocale.getDefault(Category.FORMAT);
}
if (tz == null) {
tz = TimeZone.getDefault();
/*********************************************************************
- * Copyright (C) 2000-2010, International Business Machines
+ * Copyright (C) 2000-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*********************************************************************
*/
import com.ibm.icu.impl.CalendarCache;
import com.ibm.icu.text.ChineseDateFormat;
import com.ibm.icu.text.DateFormat;
+import com.ibm.icu.util.ULocale.Category;
/**
* <code>ChineseCalendar</code> is a concrete subclass of {@link Calendar}
/**
* Constructs a <code>ChineseCalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
* @param month The value used to set the calendar's {@link #MONTH MONTH} time field.
* @param isLeapMonth The value used to set the Chinese calendar's (@link #IS_LEAP_MONTH)
* time field.
* @param date The value used to set the calendar's {@link #DATE DATE} time field.
+ * @see Category#FORMAT
* @stable ICU 4.0
*/
public ChineseCalendar(int year, int month, int isLeapMonth, int date) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
// We need to set the current time once to initialize the ChineseCalendar's
// ERA field to be the current era.
/**
* Constructs a <code>ChineseCalendar</code> with the given date
- * and time set for the default time zone with the default locale.
+ * and time set for the default time zone with the default <code>FORMAT</code> locale.
*
* @param year the value used to set the {@link #YEAR YEAR} time field in the calendar.
* @param month the value used to set the {@link #MONTH MONTH} time field in the calendar.
* in the calendar.
* @param second the value used to set the {@link #SECOND SECOND} time field
* in the calendar.
+ * @see Category#FORMAT
* @stable ICU 4.0
*/
public ChineseCalendar(int year, int month, int isLeapMonth, int date, int hour,
int minute, int second)
{
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
// We need to set the current time once to initialize the ChineseCalendar's
// ERA field to be the current era.
/**
* Constructs a <code>ChineseCalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param era The value used to set the calendar's {@link #ERA ERA} time field.
* @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
* The value is 0-based. e.g., 0 for January.
* @param isLeapMonth The value used to set the Chinese calendar's (@link #IS_LEAP_MONTH)
* time field.
- * @param date The value used to set the calendar's {@link #DATE DATE} time field.
+ * @param date The value used to set the calendar's {@link #DATE DATE} time field.
+ * @see Category#FORMAT
* @draft ICU 4.6
* @provisional This API might change or be removed in a future release.
*/
public ChineseCalendar(int era, int year, int month, int isLeapMonth, int date)
{
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
// We need to set the current time once to initialize the ChineseCalendar's
// ERA field to be the current era.
/**
* Constructs a <code>ChineseCalendar</code> with the given date
- * and time set for the default time zone with the default locale.
+ * and time set for the default time zone with the default <code>FORMAT</code> locale.
*
* @param era the value used to set the calendar's {@link #ERA ERA} time field.
* @param year the value used to set the {@link #YEAR YEAR} time field in the calendar.
* @param minute the value used to set the {@link #MINUTE MINUTE} time field
* in the calendar.
* @param second the value used to set the {@link #SECOND SECOND} time field
- * in the calendar.
+ * in the calendar.
+ * @see Category#FORMAT
* @draft ICU 4.6
* @provisional This API might change or be removed in a future release.
*/
public ChineseCalendar(int era, int year, int month, int isLeapMonth, int date, int hour,
int minute, int second)
{
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
// We need to set the current time once to initialize the ChineseCalendar's
// ERA field to be the current era.
/**
* Construct a <code>ChineseCalendar</code> based on the current time
- * in the given time zone with the default locale.
+ * in the given time zone with the default <code>FORMAT</code> locale.
* @param zone the given time zone
+ * @see Category#FORMAT
* @stable ICU 4.0
*/
public ChineseCalendar(TimeZone zone) {
- super(zone, ULocale.getDefault());
+ super(zone, ULocale.getDefault(Category.FORMAT));
setTimeInMillis(System.currentTimeMillis());
}
import com.ibm.icu.text.CurrencyMetaInfo;
import com.ibm.icu.text.CurrencyMetaInfo.CurrencyDigits;
import com.ibm.icu.text.CurrencyMetaInfo.CurrencyFilter;
+import com.ibm.icu.util.ULocale.Category;
/**
* A class encapsulating a currency, as defined by ISO 4217. A
/**
* Convenience and compatibility override of getName that
- * requests the symbol name.
+ * requests the symbol name for the default <code>DISPLAY</code> locale.
* @see #getName
+ * @see Category#DISPLAY
* @stable ICU 3.4
*/
public String getSymbol() {
- return getSymbol(ULocale.getDefault());
+ return getSymbol(ULocale.getDefault(Category.DISPLAY));
}
/**
/*
- * Copyright (C) 1996-2010, International Business Machines
+ * Copyright (C) 1996-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*/
import java.util.Date;
import java.util.Locale;
+import com.ibm.icu.util.ULocale.Category;
+
/**
* {@icuenhanced java.util.GregorianCalendar}.{@icu _usage_}
*
/**
* Constructs a default GregorianCalendar using the current time
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public GregorianCalendar() {
- this(TimeZone.getDefault(), ULocale.getDefault());
+ this(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
}
/**
* Constructs a GregorianCalendar based on the current time
- * in the given time zone with the default locale.
+ * in the given time zone with the default <code>FORMAT</code> locale.
* @param zone the given time zone.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public GregorianCalendar(TimeZone zone) {
- this(zone, ULocale.getDefault());
+ this(zone, ULocale.getDefault(Category.FORMAT));
}
/**
/**
* Constructs a GregorianCalendar with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
* @param year the value used to set the YEAR time field in the calendar.
* @param month the value used to set the MONTH time field in the calendar.
* Month value is 0-based. e.g., 0 for January.
* @param date the value used to set the DATE time field in the calendar.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public GregorianCalendar(int year, int month, int date) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
set(ERA, AD);
set(YEAR, year);
set(MONTH, month);
/**
* Constructs a GregorianCalendar with the given date
- * and time set for the default time zone with the default locale.
+ * and time set for the default time zone with the default <code>FORMAT</code> locale.
* @param year the value used to set the YEAR time field in the calendar.
* @param month the value used to set the MONTH time field in the calendar.
* Month value is 0-based. e.g., 0 for January.
* in the calendar.
* @param minute the value used to set the MINUTE time field
* in the calendar.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public GregorianCalendar(int year, int month, int date, int hour,
int minute) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
set(ERA, AD);
set(YEAR, year);
set(MONTH, month);
/**
* Constructs a GregorianCalendar with the given date
- * and time set for the default time zone with the default locale.
+ * and time set for the default time zone with the default <code>FORMAT</code> locale.
* @param year the value used to set the YEAR time field in the calendar.
* @param month the value used to set the MONTH time field in the calendar.
* Month value is 0-based. e.g., 0 for January.
* in the calendar.
* @param second the value used to set the SECOND time field
* in the calendar.
+ * @see Category#FORMAT
* @stable ICU 2.0
*/
public GregorianCalendar(int year, int month, int date, int hour,
int minute, int second) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
set(ERA, AD);
set(YEAR, year);
set(MONTH, month);
/*
*******************************************************************************
- * Copyright (C) 1996-2010, International Business Machines Corporation and *
+ * Copyright (C) 1996-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
import java.util.Locale;
import com.ibm.icu.impl.CalendarCache;
+import com.ibm.icu.util.ULocale.Category;
/**
* <code>HebrewCalendar</code> is a subclass of <code>Calendar</code>
/**
* Constructs a default <code>HebrewCalendar</code> using the current time
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public HebrewCalendar() {
- this(TimeZone.getDefault(), ULocale.getDefault());
+ this(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
}
/**
* Constructs a <code>HebrewCalendar</code> based on the current time
- * in the given time zone with the default locale.
+ * in the given time zone with the default <code>FORMAT</code> locale.
*
* @param zone The time zone for the new calendar.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public HebrewCalendar(TimeZone zone) {
- this(zone, ULocale.getDefault());
+ this(zone, ULocale.getDefault(Category.FORMAT));
}
/**
/**
* Constructs a <code>HebrewCalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
*
* The value is 0-based. e.g., 0 for Tishri.
*
* @param date The value used to set the calendar's {@link #DATE DATE} time field.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public HebrewCalendar(int year, int month, int date) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.set(YEAR, year);
this.set(MONTH, month);
this.set(DATE, date);
/**
* Constructs a <code>HebrewCalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param date The date to which the new calendar is set.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public HebrewCalendar(Date date) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.setTime(date);
}
/**
* Constructs a <code>HebrewCalendar</code> with the given date
- * and time set for the default time zone with the default locale.
+ * and time set for the default time zone with the default <code>FORMAT</code> locale.
*
* @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
*
* @param minute The value used to set the calendar's {@link #MINUTE MINUTE} time field.
*
* @param second The value used to set the calendar's {@link #SECOND SECOND} time field.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public HebrewCalendar(int year, int month, int date, int hour,
int minute, int second)
{
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.set(YEAR, year);
this.set(MONTH, month);
this.set(DATE, date);
/*
*******************************************************************************
- * Copyright (C) 1996-2010, International Business Machines Corporation and *
+ * Copyright (C) 1996-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import com.ibm.icu.util.ULocale.Category;
+
/**
* <b>Note:</b> The Holiday framework is a technology preview.
* Despite its age, is still draft API, and clients should treat it as such.
*/
public static Holiday[] getHolidays()
{
- return getHolidays(ULocale.getDefault());
+ return getHolidays(ULocale.getDefault(Category.FORMAT));
}
/**
}
/**
- * Return the name of this holiday in the language of the default locale.
+ * Return the name of this holiday in the language of the default <code>DISPLAY</code> locale.
+ * @see Category#DISPLAY
* @draft ICU 2.8
* @provisional This API might change or be removed in a future release.
*/
public String getDisplayName() {
- return getDisplayName(ULocale.getDefault());
+ return getDisplayName(ULocale.getDefault(Category.DISPLAY));
}
/**
import java.util.Date;
import java.util.Locale;
+import com.ibm.icu.util.ULocale.Category;
+
/**
* <code>IndianCalendar</code> is a subclass of <code>GregorianCalendar</code>
* that numbers years since the birth of the Buddha. This is the civil calendar
/**
* Constructs a <code>IndianCalendar</code> using the current time
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 3.8
*/
public IndianCalendar() {
- this(TimeZone.getDefault(), ULocale.getDefault());
+ this(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
}
/**
* Constructs a <code>IndianCalendar</code> based on the current time
- * in the given time zone with the default locale.
+ * in the given time zone with the default <code>FORMAT</code> locale.
*
* @param zone the given time zone.
+ * @see Category#FORMAT
* @stable ICU 3.8
*/
public IndianCalendar(TimeZone zone) {
- this(zone, ULocale.getDefault());
+ this(zone, ULocale.getDefault(Category.FORMAT));
}
/**
/**
* Constructs a <code>IndianCalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param date The date to which the new calendar is set.
+ * @see Category#FORMAT
* @stable ICU 3.8
*/
public IndianCalendar(Date date) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.setTime(date);
}
/**
* Constructs a <code>IndianCalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
*
* The value is 0-based. e.g., 0 for January.
*
* @param date The value used to set the calendar's {@link #DATE DATE} time field.
+ * @see Category#FORMAT
* @stable ICU 3.8
*/
public IndianCalendar(int year, int month, int date) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.set(Calendar.YEAR, year);
this.set(Calendar.MONTH, month);
this.set(Calendar.DATE, date);
/**
* Constructs a IndianCalendar with the given date
- * and time set for the default time zone with the default locale.
+ * and time set for the default time zone with the default <code>FORMAT</code> locale.
*
* @param year The value used to set the calendar's {@link #YEAR YEAR} time field.
*
* @param minute The value used to set the calendar's {@link #MINUTE MINUTE} time field.
*
* @param second The value used to set the calendar's {@link #SECOND SECOND} time field.
+ * @see Category#FORMAT
* @stable ICU 3.8
*/
public IndianCalendar(int year, int month, int date, int hour,
int minute, int second)
{
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.set(Calendar.YEAR, year);
this.set(Calendar.MONTH, month);
this.set(Calendar.DATE, date);
import com.ibm.icu.impl.CalendarAstronomer;
import com.ibm.icu.impl.CalendarCache;
+import com.ibm.icu.util.ULocale.Category;
/**
* <code>IslamicCalendar</code> is a subclass of <code>Calendar</code>
/**
* Constructs a default <code>IslamicCalendar</code> using the current time
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public IslamicCalendar()
{
- this(TimeZone.getDefault(), ULocale.getDefault());
+ this(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
}
/**
* Constructs an <code>IslamicCalendar</code> based on the current time
- * in the given time zone with the default locale.
+ * in the given time zone with the default <code>FORMAT</code> locale.
* @param zone the given time zone.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public IslamicCalendar(TimeZone zone)
{
- this(zone, ULocale.getDefault());
+ this(zone, ULocale.getDefault(Category.FORMAT));
}
/**
/**
* Constructs an <code>IslamicCalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param date The date to which the new calendar is set.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public IslamicCalendar(Date date) {
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.setTime(date);
}
/**
* Constructs an <code>IslamicCalendar</code> with the given date set
- * in the default time zone with the default locale.
+ * in the default time zone with the default <code>FORMAT</code> locale.
*
* @param year the value used to set the {@link #YEAR YEAR} time field in the calendar.
* @param month the value used to set the {@link #MONTH MONTH} time field in the calendar.
* Note that the month value is 0-based. e.g., 0 for Muharram.
* @param date the value used to set the {@link #DATE DATE} time field in the calendar.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public IslamicCalendar(int year, int month, int date)
{
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.set(Calendar.YEAR, year);
this.set(Calendar.MONTH, month);
this.set(Calendar.DATE, date);
/**
* Constructs an <code>IslamicCalendar</code> with the given date
- * and time set for the default time zone with the default locale.
+ * and time set for the default time zone with the default <code>FORMAT</code> locale.
*
* @param year the value used to set the {@link #YEAR YEAR} time field in the calendar.
* @param month the value used to set the {@link #MONTH MONTH} time field in the calendar.
* in the calendar.
* @param second the value used to set the {@link #SECOND SECOND} time field
* in the calendar.
+ * @see Category#FORMAT
* @stable ICU 2.8
*/
public IslamicCalendar(int year, int month, int date, int hour,
int minute, int second)
{
- super(TimeZone.getDefault(), ULocale.getDefault());
+ super(TimeZone.getDefault(), ULocale.getDefault(Category.FORMAT));
this.set(Calendar.YEAR, year);
this.set(Calendar.MONTH, month);
this.set(Calendar.DATE, date);
/*
**************************************************************************************
- * Copyright (C) 2009-2010, Google, Inc.; International Business Machines Corporation *
+ * Copyright (C) 2009-2011, Google, Inc.; International Business Machines Corporation *
* and others. All Rights Reserved. *
**************************************************************************************
*/
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.text.UnicodeSet;
+import com.ibm.icu.util.ULocale.Category;
/**
* A class for accessing miscelleneous data in the locale bundles
}
/**
- * Gets the LocaleData object associated with the default locale
+ * Gets the LocaleData object associated with the default <code>FORMAT</code> locale
*
* @return A locale data object.
+ * @see Category#FORMAT
* @stable ICU 3.4
*/
public static final LocaleData getInstance() {
- return LocaleData.getInstance(ULocale.getDefault());
+ return LocaleData.getInstance(ULocale.getDefault(Category.FORMAT));
}
/**
import com.ibm.icu.text.TimeZoneFormat.TimeType;
import com.ibm.icu.text.TimeZoneNames;
import com.ibm.icu.text.TimeZoneNames.NameType;
+import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.util.TimeZone}.{@icu _usage_}
/**
* Returns a name of this time zone suitable for presentation to the user
- * in the default locale.
+ * in the default <code>DISPLAY</code> locale.
* This method returns the long generic name.
* If the display name is not available for the locale,
* 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.
+ * @see Category#DISPLAY
* @stable ICU 2.0
*/
public final String getDisplayName() {
- return _getDisplayName(LONG_GENERIC, false, ULocale.getDefault());
+ return _getDisplayName(LONG_GENERIC, false, ULocale.getDefault(Category.DISPLAY));
}
/**
/**
* Returns a name of this time zone suitable for presentation to the user
- * in the default locale.
+ * in the default <code>DISPLAY</code> locale.
* If the display name is not available for the locale,
* then this method returns a string in the localized GMT offset format
* such as <code>GMT[+-]HH:mm</code>.
* <code>LONG_GENERIC</code>, <code>SHORT_GMT</code>, <code>LONG_GMT</code>,
* <code>SHORT_COMMONLY_USED</code> or <code>GENERIC_LOCATION</code>.
* @return the human-readable name of this time zone in the default locale.
+ * @see Category#DISPLAY
* @stable ICU 2.0
*/
public final String getDisplayName(boolean daylight, int style) {
- return getDisplayName(daylight, style, ULocale.getDefault());
+ return getDisplayName(daylight, style, ULocale.getDefault(Category.DISPLAY));
}
/**
*/
public static final ULocale ROOT = new ULocale("", EMPTY_LOCALE);
+ /**
+ * Enum for locale categories. These locale categories are used to get/set the default locale for
+ * the specific functionality represented by the category.
+ * @stable ICU 49
+ */
+ public enum Category {
+ /**
+ * Category used to represent the default locale for displaying user interfaces.
+ * @stable ICU 49
+ */
+ DISPLAY,
+ /**
+ * Category used to represent the default locale for formatting date, number and/or currency.
+ * @stable ICU 49
+ */
+ FORMAT
+ }
+
private static final SimpleCache<Locale, ULocale> CACHE = new SimpleCache<Locale, ULocale>();
/**
}
ULocale result = CACHE.get(loc);
if (result == null) {
- if (defaultULocale != null && loc == defaultULocale.locale) {
- result = defaultULocale;
- } else {
- result = JDKLocaleMapper.INSTANCE.toULocale(loc);
- }
+ result = JDKLocaleHelper.toULocale(loc);
CACHE.put(loc, result);
}
return result;
*/
public Locale toLocale() {
if (locale == null) {
- locale = JDKLocaleMapper.INSTANCE.toLocale(this);
+ locale = JDKLocaleHelper.toLocale(this);
}
return locale;
}
private static ICUCache<String, String> nameCache = new SimpleCache<String, String>();
+
/**
* Keep our own default ULocale.
*/
private static Locale defaultLocale = Locale.getDefault();
- private static ULocale defaultULocale = new ULocale(defaultLocale);
+ private static ULocale defaultULocale = forLocale(defaultLocale);
+
+ private static Locale[] defaultCategoryLocales = new Locale[Category.values().length];
+ private static ULocale[] defaultCategoryULocales = new ULocale[Category.values().length];
+
+ static {
+ for (Category cat: Category.values()) {
+ int idx = cat.ordinal();
+ defaultCategoryLocales[idx] = JDKLocaleHelper.getDefault(cat);
+ defaultCategoryULocales[idx] = forLocale(defaultCategoryLocales[idx]);
+ }
+ }
/**
* Returns the current default ULocale.
+ * @return the default ULocale.
* @stable ICU 2.8
*/
public static ULocale getDefault() {
synchronized (ULocale.class) {
- Locale currentDefault = Locale.getDefault();
- if (!defaultLocale.equals(currentDefault)) {
- defaultLocale = currentDefault;
- defaultULocale = new ULocale(defaultLocale);
- }
if (defaultULocale == null) {
// When Java's default locale has extensions (such as ja-JP-u-ca-japanese),
// Locale -> ULocale mapping requires BCP47 keyword mapping data that is currently
return ULocale.ROOT;
}
+ Locale currentDefault = Locale.getDefault();
+ if (!defaultLocale.equals(currentDefault)) {
+ defaultLocale = currentDefault;
+ defaultULocale = forLocale(currentDefault);
+
+ if (!JDKLocaleHelper.isJava7orNewer()) {
+ // Detected Java default Locale change.
+ // We need to update category defaults to match the
+ // Java 7's behavior on Java 6 or older environment.
+ for (Category cat : Category.values()) {
+ int idx = cat.ordinal();
+ defaultCategoryLocales[idx] = currentDefault;
+ defaultCategoryULocales[idx] = forLocale(currentDefault);
+ }
+ }
+ }
return defaultULocale;
}
}
* If the caller does not have write permission to the
* user.language property, a security exception will be thrown,
* and the default ULocale will remain unchanged.
+ * <p>
+ * By setting the default ULocale with this method, all of the default categoy locales
+ * are also set to the specified default ULocale.
* @param newLocale the new default locale
* @throws SecurityException if a security manager exists and its
* <code>checkPermission</code> method doesn't allow the operation.
* @throws NullPointerException if <code>newLocale</code> is null
* @see SecurityManager#checkPermission(java.security.Permission)
* @see java.util.PropertyPermission
+ * @see ULocale#setDefault(Category, ULocale)
* @stable ICU 3.0
*/
public static synchronized void setDefault(ULocale newLocale){
Locale.setDefault(newLocale.toLocale());
defaultULocale = newLocale;
+ // This method also updates all category default locales
+ for (Category cat : Category.values()) {
+ setDefault(cat, newLocale);
+ }
+ }
+
+ /**
+ * Returns the current default ULocale for the specified category.
+ *
+ * @param category the category
+ * @return the default ULocale for the specified category.
+ * @stable ICU 49
+ */
+ public static ULocale getDefault(Category category) {
+ synchronized (ULocale.class) {
+ int idx = category.ordinal();
+ if (defaultCategoryULocales[idx] == null) {
+ // Just in case this method is called during ULocale class
+ // initialization. Unlike getDefault(), we do not have
+ // cyclic dependency for category default.
+ return ULocale.ROOT;
+ }
+ if (JDKLocaleHelper.isJava7orNewer()) {
+ Locale currentCategoryDefault = JDKLocaleHelper.getDefault(category);
+ if (!defaultCategoryLocales[idx].equals(currentCategoryDefault)) {
+ defaultCategoryLocales[idx] = currentCategoryDefault;
+ defaultCategoryULocales[idx] = forLocale(currentCategoryDefault);
+ }
+ } else {
+ // java.util.Locale.setDefault(Locale) in Java 7 updates
+ // category locale defaults. On Java 6 or older environment,
+ // ICU4J checks if the default locale has changed and update
+ // category ULocales here if necessary.
+
+ // Note: When java.util.Locale.setDefault(Locale) is called
+ // with a Locale same with the previous one, Java 7 still
+ // updates category locale defaults. On Java 6 or older env,
+ // there is no good way to detect the event, ICU4J simply
+ // check if the default Java Locale has changed since last
+ // time.
+
+ Locale currentDefault = Locale.getDefault();
+ if (!defaultLocale.equals(currentDefault)) {
+ defaultLocale = currentDefault;
+ defaultULocale = forLocale(currentDefault);
+
+ for (Category cat : Category.values()) {
+ int tmpIdx = cat.ordinal();
+ defaultCategoryLocales[tmpIdx] = currentDefault;
+ defaultCategoryULocales[tmpIdx] = forLocale(currentDefault);
+ }
+ }
+
+ // No synchronization with JDK Locale, because category default
+ // is not supported in Java 6 or older versions
+ }
+ return defaultCategoryULocales[idx];
+ }
+ }
+
+ /**
+ * Sets the default <code>ULocale</code> for the specified <code>Category</code>.
+ * This also sets the default <code>Locale</code> for the specified <code>Category</code>
+ * of the JVM. If the caller does not have write permission to the
+ * user.language property, a security exception will be thrown,
+ * and the default ULocale for the specified Category will remain unchanged.
+ *
+ * @param category the specified category to set the default locale
+ * @param newLocale the new default locale
+ * @see SecurityManager#checkPermission(java.security.Permission)
+ * @see java.util.PropertyPermission
+ * @stable ICU 49
+ */
+ public static synchronized void setDefault(Category category, ULocale newLocale) {
+ Locale newJavaDefault = newLocale.toLocale();
+ int idx = category.ordinal();
+ defaultCategoryULocales[idx] = newLocale;
+ defaultCategoryLocales[idx] = newJavaDefault;
+ JDKLocaleHelper.setDefault(category, newJavaDefault);
}
/**
// display names
/**
- * Returns this locale's language localized for display in the default locale.
+ * Returns this locale's language localized for display in the default <code>DISPLAY</code> locale.
* @return the localized language name.
+ * @see Category#DISPLAY
* @stable ICU 3.0
*/
public String getDisplayLanguage() {
- return getDisplayLanguageInternal(this, getDefault(), false);
+ return getDisplayLanguageInternal(this, getDefault(Category.DISPLAY), false);
}
/**
return getDisplayLanguageInternal(new ULocale(localeID), displayLocale, false);
}
/**
- * {@icu} Returns this locale's language localized for display in the default locale.
+ * {@icu} Returns this locale's language localized for display in the default <code>DISPLAY</code> locale.
* If a dialect name is present in the data, then it is returned.
* @return the localized language name.
+ * @see Category#DISPLAY
* @stable ICU 4.4
*/
public String getDisplayLanguageWithDialect() {
- return getDisplayLanguageInternal(this, getDefault(), true);
+ return getDisplayLanguageInternal(this, getDefault(Category.DISPLAY), true);
}
/**
}
/**
- * {@icu} Returns this locale's script localized for display in the default locale.
+ * {@icu} Returns this locale's script localized for display in the default <code>DISPLAY</code> locale.
* @return the localized script name.
+ * @see Category#DISPLAY
* @stable ICU 3.0
*/
public String getDisplayScript() {
- return getDisplayScriptInternal(this, getDefault());
+ return getDisplayScriptInternal(this, getDefault(Category.DISPLAY));
}
/**
}
/**
- * Returns this locale's country localized for display in the default locale.
+ * Returns this locale's country localized for display in the default <code>DISPLAY</code> locale.
* @return the localized country name.
+ * @see Category#DISPLAY
* @stable ICU 3.0
*/
public String getDisplayCountry() {
- return getDisplayCountryInternal(this, getDefault());
+ return getDisplayCountryInternal(this, getDefault(Category.DISPLAY));
}
/**
}
/**
- * Returns this locale's variant localized for display in the default locale.
+ * Returns this locale's variant localized for display in the default <code>DISPLAY</code> locale.
* @return the localized variant name.
+ * @see Category#DISPLAY
* @stable ICU 3.0
*/
public String getDisplayVariant() {
- return getDisplayVariantInternal(this, getDefault());
+ return getDisplayVariantInternal(this, getDefault(Category.DISPLAY));
}
/**
}
/**
- * {@icu} Returns a keyword localized for display in the default locale.
+ * {@icu} Returns a keyword localized for display in the default <code>DISPLAY</code> locale.
* @param keyword the keyword to be displayed.
* @return the localized keyword name.
* @see #getKeywords()
+ * @see Category#DISPLAY
* @stable ICU 3.0
*/
public static String getDisplayKeyword(String keyword) {
- return getDisplayKeywordInternal(keyword, getDefault());
+ return getDisplayKeywordInternal(keyword, getDefault(Category.DISPLAY));
}
/**
}
/**
- * {@icu} Returns a keyword value localized for display in the default locale.
+ * {@icu} Returns a keyword value localized for display in the default <code>DISPLAY</code> locale.
* @param keyword the keyword whose value is to be displayed.
* @return the localized value name.
+ * @see Category#DISPLAY
* @stable ICU 3.0
*/
public String getDisplayKeywordValue(String keyword) {
- return getDisplayKeywordValueInternal(this, keyword, getDefault());
+ return getDisplayKeywordValueInternal(this, keyword, getDefault(Category.DISPLAY));
}
/**
}
/**
- * Returns this locale name localized for display in the default locale.
+ * Returns this locale name localized for display in the default <code>DISPLAY</code> locale.
* @return the localized locale name.
+ * @see Category#DISPLAY
* @stable ICU 3.0
*/
public String getDisplayName() {
- return getDisplayNameInternal(this, getDefault());
+ return getDisplayNameInternal(this, getDefault(Category.DISPLAY));
}
/**
}
/**
- * {@icu} Returns this locale name localized for display in the default locale.
+ * {@icu} Returns this locale name localized for display in the default <code>DISPLAY</code> locale.
* If a dialect name is present in the locale data, then it is returned.
* @return the localized locale name.
+ * @see Category#DISPLAY
* @stable ICU 4.4
*/
public String getDisplayNameWithDialect() {
- return getDisplayNameWithDialectInternal(this, getDefault());
+ return getDisplayNameWithDialectInternal(this, getDefault(Category.DISPLAY));
}
/**
}
/*
- * JDK Locale Mapper
+ * JDK Locale Helper
*/
- private static final class JDKLocaleMapper {
- public static final JDKLocaleMapper INSTANCE = new JDKLocaleMapper();
-
+ private static final class JDKLocaleHelper {
private static boolean isJava7orNewer = false;
/*
private static Method mGetUnicodeLocaleType;
private static Method mForLanguageTag;
+ private static Method mGetDefault;
+ private static Method mSetDefault;
+ private static Object eDISPLAY;
+ private static Object eFORMAT;
+
/*
* This table is used for mapping between ICU and special Java
* 6 locales. When an ICU locale matches <minumum base> with
};
static {
- try {
- mGetScript = Locale.class.getMethod("getScript", (Class[]) null);
- mGetExtensionKeys = Locale.class.getMethod("getExtensionKeys", (Class[]) null);
- mGetExtension = Locale.class.getMethod("getExtension", char.class);
- mGetUnicodeLocaleKeys = Locale.class.getMethod("getUnicodeLocaleKeys", (Class[]) null);
- mGetUnicodeLocaleAttributes = Locale.class.getMethod("getUnicodeLocaleAttributes", (Class[]) null);
- mGetUnicodeLocaleType = Locale.class.getMethod("getUnicodeLocaleType", String.class);
- mForLanguageTag = Locale.class.getMethod("forLanguageTag", String.class);
- isJava7orNewer = true;
- } catch (NoSuchMethodException e) {
- // Java 6 or older
- }
+ do {
+ try {
+ mGetScript = Locale.class.getMethod("getScript", (Class[]) null);
+ mGetExtensionKeys = Locale.class.getMethod("getExtensionKeys", (Class[]) null);
+ mGetExtension = Locale.class.getMethod("getExtension", char.class);
+ mGetUnicodeLocaleKeys = Locale.class.getMethod("getUnicodeLocaleKeys", (Class[]) null);
+ mGetUnicodeLocaleAttributes = Locale.class.getMethod("getUnicodeLocaleAttributes", (Class[]) null);
+ mGetUnicodeLocaleType = Locale.class.getMethod("getUnicodeLocaleType", String.class);
+ mForLanguageTag = Locale.class.getMethod("forLanguageTag", String.class);
+
+ Class<?> cCategory = null;
+ Class<?>[] classes = Locale.class.getDeclaredClasses();
+ for (Class<?> c : classes) {
+ if (c.getName().equals("java.util.Locale$Category")) {
+ cCategory = c;
+ break;
+ }
+ }
+ if (cCategory == null) {
+ break;
+ }
+ mGetDefault = Locale.class.getDeclaredMethod("getDefault", cCategory);
+ mSetDefault = Locale.class.getDeclaredMethod("setDefault", cCategory, Locale.class);
+
+ Method mName = cCategory.getMethod("name", (Class[]) null);
+ Object[] enumConstants = cCategory.getEnumConstants();
+ for (Object e : enumConstants) {
+ String catVal = (String)mName.invoke(e, (Object[])null);
+ if (catVal.equals("DISPLAY")) {
+ eDISPLAY = e;
+ } else if (catVal.equals("FORMAT")) {
+ eFORMAT = e;
+ }
+ }
+ if (eDISPLAY == null || eFORMAT == null) {
+ break;
+ }
+ isJava7orNewer = true;
+ } catch (NoSuchMethodException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException e) {
+ } catch (SecurityException e) {
+ // TODO : report?
+ }
+ } while (false);
+ }
+
+ private JDKLocaleHelper() {
}
- private JDKLocaleMapper() {
+ public static boolean isJava7orNewer() {
+ return isJava7orNewer;
}
- public ULocale toULocale(Locale loc) {
+ public static ULocale toULocale(Locale loc) {
return isJava7orNewer ? toULocale7(loc) : toULocale6(loc);
}
- public Locale toLocale(ULocale uloc) {
+ public static Locale toLocale(ULocale uloc) {
return isJava7orNewer ? toLocale7(uloc) : toLocale6(uloc);
}
- private ULocale toULocale7(Locale loc) {
+ private static ULocale toULocale7(Locale loc) {
String language = loc.getLanguage();
String script = "";
String country = loc.getCountry();
return new ULocale(getName(buf.toString()), loc);
}
- private ULocale toULocale6(Locale loc) {
+ private static ULocale toULocale6(Locale loc) {
ULocale uloc = null;
String locStr = loc.toString();
if (locStr.length() == 0) {
return uloc;
}
- private Locale toLocale7(ULocale uloc) {
+ private static Locale toLocale7(ULocale uloc) {
Locale loc = null;
String ulocStr = uloc.getName();
if (uloc.getScript().length() > 0 || ulocStr.contains("@")) {
return loc;
}
- private Locale toLocale6(ULocale uloc) {
+ private static Locale toLocale6(ULocale uloc) {
String locstr = uloc.getBaseName();
for (int i = 0; i < JAVA6_MAPDATA.length; i++) {
if (locstr.equals(JAVA6_MAPDATA[i][1]) || locstr.equals(JAVA6_MAPDATA[i][4])) {
String[] names = p.getLanguageScriptCountryVariant();
return new Locale(names[0], names[2], names[3]);
}
+
+ public static Locale getDefault(Category category) {
+ Locale loc = Locale.getDefault();
+ if (isJava7orNewer) {
+ Object cat = null;
+ switch (category) {
+ case DISPLAY:
+ cat = eDISPLAY;
+ break;
+ case FORMAT:
+ cat = eFORMAT;
+ break;
+ }
+ if (cat != null) {
+ try {
+ loc = (Locale)mGetDefault.invoke(null, cat);
+ } catch (InvocationTargetException e) {
+ // fall through - use the base default
+ } catch (IllegalArgumentException e) {
+ // fall through - use the base default
+ } catch (IllegalAccessException e) {
+ // fall through - use the base default
+ }
+ }
+ }
+ return loc;
+ }
+
+ public static void setDefault(Category category, Locale newLocale) {
+ if (isJava7orNewer) {
+ Object cat = null;
+ switch (category) {
+ case DISPLAY:
+ cat = eDISPLAY;
+ break;
+ case FORMAT:
+ cat = eFORMAT;
+ break;
+ }
+ if (cat != null) {
+ try {
+ mSetDefault.invoke(null, cat, newLocale);
+ } catch (InvocationTargetException e) {
+ // fall through - no effects
+ } catch (IllegalArgumentException e) {
+ // fall through - no effects
+ } catch (IllegalAccessException e) {
+ // fall through - no effects
+ }
+ }
+ }
+ }
}
}
import com.ibm.icu.util.CaseInsensitiveString;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
+import com.ibm.icu.util.ULocale.Category;
/**
* <code>Transliterator</code> is an abstract class that transliterates text from one format to another. The most common
/**
* Returns a name for this transliterator that is appropriate for
- * display to the user in the default locale. See {@link
+ * display to the user in the default <code>DISPLAY</code> locale. See {@link
* #getDisplayName(String,Locale)} for details.
+ * @see com.ibm.icu.util.ULocale.Category#DISPLAY
* @stable ICU 2.0
*/
public final static String getDisplayName(String ID) {
- return getDisplayName(ID, ULocale.getDefault());
+ return getDisplayName(ID, ULocale.getDefault(Category.DISPLAY));
}
/**
import com.ibm.icu.util.LocaleData;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.ULocale.Builder;
+import com.ibm.icu.util.ULocale.Category;
import com.ibm.icu.util.UResourceBundle;
import com.ibm.icu.util.VersionInfo;
}
}
}
+
+ public void TestCategoryDefault() {
+ Locale backupDefault = Locale.getDefault();
+
+ ULocale orgDefault = ULocale.getDefault();
+
+ // Setting a category default won't change default ULocale
+ ULocale uJaJp = new ULocale("ja_JP");
+ ULocale uDeDePhonebook = new ULocale("de_DE@collation=phonebook");
+
+ ULocale.setDefault(Category.DISPLAY, uJaJp);
+ ULocale.setDefault(Category.FORMAT, uDeDePhonebook);
+
+ if (!ULocale.getDefault().equals(orgDefault)) {
+ errln("FAIL: Default ULocale is " + ULocale.getDefault() + ", expected: " + orgDefault);
+ }
+
+ if (!ULocale.getDefault(Category.DISPLAY).equals(uJaJp)) {
+ errln("FAIL: DISPLAY ULocale is " + ULocale.getDefault(Category.DISPLAY) + ", expected: " + uJaJp);
+ }
+
+ if (!ULocale.getDefault(Category.FORMAT).equals(uDeDePhonebook)) {
+ errln("FAIL: FORMAT ULocale is " + ULocale.getDefault(Category.FORMAT) + ", expected: " + uDeDePhonebook);
+ }
+
+ // Setting ULocale default will overrides category defaults
+ ULocale uFrFr = new ULocale("fr_FR");
+
+ ULocale.setDefault(uFrFr);
+
+ if (!ULocale.getDefault(Category.DISPLAY).equals(uFrFr)) {
+ errln("FAIL: DISPLAY ULocale is " + ULocale.getDefault(Category.DISPLAY) + ", expected: " + uFrFr);
+ }
+
+ if (!ULocale.getDefault(Category.FORMAT).equals(uFrFr)) {
+ errln("FAIL: FORMAT ULocale is " + ULocale.getDefault(Category.FORMAT) + ", expected: " + uFrFr);
+ }
+
+ // Setting Locale default will updates ULocale default and category defaults
+ Locale arEg = new Locale("ar", "EG");
+ ULocale uArEg = ULocale.forLocale(arEg);
+
+ Locale.setDefault(arEg);
+
+ if (!ULocale.getDefault().equals(uArEg)) {
+ errln("FAIL: Default ULocale is " + ULocale.getDefault() + ", expected: " + uArEg);
+ }
+
+ if (!ULocale.getDefault(Category.DISPLAY).equals(uArEg)) {
+ errln("FAIL: DISPLAY ULocale is " + ULocale.getDefault(Category.DISPLAY) + ", expected: " + uArEg);
+ }
+
+ if (!ULocale.getDefault(Category.FORMAT).equals(uArEg)) {
+ errln("FAIL: FORMAT ULocale is " + ULocale.getDefault(Category.FORMAT) + ", expected: " + uArEg);
+ }
+
+ // Restore back up
+ Locale.setDefault(backupDefault);
+ }
}