Top Description Fields Constructors Methods
com.ibm.icu.util

public Class GlobalizationPreferences

extends Object
implements Freezable<GlobalizationPreferences>
Class Inheritance
All Implemented Interfaces
com.ibm.icu.util.Freezable, java.lang.Cloneable
Imports
java.util.ArrayList, .Arrays, .BitSet, .Date, .HashMap, .List, .Map, .MissingResourceException, .ResourceBundle, .Set, com.ibm.icu.impl.Utility, com.ibm.icu.text.BreakIterator, .Collator, .DateFormat, .NumberFormat, .SimpleDateFormat

This convenience class provides a mechanism for bundling together different globalization preferences. It includes: The class will heuristically compute implicit, heuristic values for the above based on available data if explicit values are not supplied. These implicit values can be presented to users for confirmation, or replacement if the values are incorrect.

To reset any explicit field so that it will get heuristic values, pass in null. For example, myPreferences.setLocale(null);

All of the heuristics can be customized by subclasses, by overriding getTerritory(), guessCollator(), etc.

The class also supplies display names for languages, scripts, territories, currencies, timezones, etc. These are computed according to the locale/language preference list. Thus, if the preference is Breton; French; English, then the display name for a language will be returned in Breton if available, otherwise in French if available, otherwise in English.

The codes used to reference territory, currency, etc. are as defined elsewhere in ICU, and are taken from CLDR (which reflects RFC 3066bis usage, ISO 4217, and the TZ Timezone database identifiers).

This is at a prototype stage, and has not incorporated all the design changes that we would like yet; further feedback is welcome.

Note:
ICU Status
Draft since ICU 3.6 (retainAll).

Field Summary

Modifier and TypeField and Description
private static final HashMap<ULocale, BitSet>
public static final int
BI_CHARACTER

Break iterator type

private static final int
public static final int
BI_LINE

Break iterator type

public static final int
BI_SENTENCE

Break iterator type

public static final int
BI_TITLE

Break iterator type

public static final int
BI_WORD

Break iterator type

private BreakIterator[]
private Calendar
private Collator
private Currency
private DateFormat[][]
public static final int
DF_FULL

Date Format type

private static final int
public static final int
DF_LONG

Date Format type

public static final int
DF_MEDIUM

Date Format type

public static final int
DF_NONE

Date Format type

public static final int
DF_SHORT

Date Format type

private volatile boolean
public static final int
ID_CURRENCY

For selecting a choice of display names

public static final int
ID_CURRENCY_SYMBOL

For selecting a choice of display names

public static final int
ID_KEYWORD

For selecting a choice of display names

public static final int
ID_KEYWORD_VALUE

For selecting a choice of display names

public static final int
ID_LANGUAGE

For selecting a choice of display names

public static final int
ID_LOCALE

For selecting a choice of display names

public static final int
ID_SCRIPT

For selecting a choice of display names

public static final int
ID_TERRITORY

For selecting a choice of display names

public static final int
ID_TIMEZONE

For selecting a choice of display names

public static final int
ID_VARIANT

For selecting a choice of display names

private List<ULocale>
private static final String[][]
private static final Map<String, String>
language_territory_hack_map

Warning

All of this data is temporary, until we start importing from CLDR!!!

private List<ULocale>
public static final int
NF_CURRENCY

Number Format type

public static final int
NF_INTEGER

Number Format type

private static final int
public static final int
NF_NUMBER

Number Format type

public static final int
NF_PERCENT

Number Format type

public static final int
NF_SCIENTIFIC

Number Format type

private NumberFormat[]
private String
pack-priv static final String[][]
pack-priv static final Map<String, String>
private TimeZone
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
GlobalizationPreferences()

Default constructor

Method Summary

Modifier and TypeMethod and Description
public GlobalizationPreferences
cloneAsThawed()

Implements com.ibm.icu.util.Freezable.cloneAsThawed.

Provides for the clone operation.
public GlobalizationPreferences
freeze()

Implements com.ibm.icu.util.Freezable.freeze.

Freezes the object.
private ULocale
public BreakIterator

Returns:

break iterator explicit or implicit
getBreakIterator
(int
break type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE
type
)

Get a copy of the break iterator for the specified type according to the settings.

public Calendar

Returns:

calendar explicit or implicit.
getCalendar
()

Get a copy of the calendar according to the settings.

public Collator

Returns:

collator explicit or implicit.
getCollator
()

Get a copy of the collator according to the settings.

public Currency

Returns:

currency code, explicit or implicit.
getCurrency
()

Get a copy of the currency computed according to the settings.

public DateFormat

Returns:

a DateFormat, according to the above description
getDateFormat
(int
DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE
dateStyle
,
int
DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE
timeStyle
)

Gets a date format according to the current settings.

public String

Returns:

the display name
getDisplayName
(String
language code, script code, ...
id
,
int
specifies the type of the ID: ID_LANGUAGE, etc.
type
)

Get the display name for an ID: language, script, territory, currency, timezone...

public ULocale

Returns:

desired item. null if index is out of range
getLocale
(int
The index (0..n) of the desired item.
index
)

Convenience function for getting the locales in priority order

public List<ULocale>

Returns:

a copy of the language/locale priority list.
getLocales
()

Get a copy of the language/locale priority list

public NumberFormat
getNumberFormat(int
NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER
style
)

Gets a number format according to the current settings.

public ResourceBundle

Returns:

a resource bundle for the given base name and locale based on the language/locale priority list stored in this object
getResourceBundle
(String
the base name of the resource bundle, a fully qualified class name
baseName
)

Convenience function to get a ResourceBundle instance using the specified base name based on the language/locale priority list stored in this object.

public ResourceBundle

Returns:

a resource bundle for the given base name and locale based on the language/locale priority list stored in this object
getResourceBundle
(String
the base name of the resource bundle, a fully qualified class name
baseName
,
ClassLoader
the class object from which to load the resource bundle
loader
)

Convenience function to get a ResourceBundle instance using the specified base name and class loader based on the language/locale priority list stored in this object.

public String

Returns:

territory code, explicit or implicit.
getTerritory
()

Gets the territory setting.

public TimeZone

Returns:

timezone, either implicitly or explicitly set
getTimeZone
()

Get the timezone.

protected BreakIterator
guessBreakIterator(int type)

This function can be overridden by subclasses to use different heuristics.

protected Calendar
guessCalendar()

This function can be overridden by subclasses to use different heuristics.

protected Collator
guessCollator()

This function can be overridden by subclasses to use different heuristics.

protected Currency
guessCurrency()

This function can be overridden by subclasses to use different heuristics

protected DateFormat
guessDateFormat(int dateStyle, int timeStyle)

This function can be overridden by subclasses to use different heuristics.

protected List<ULocale>
guessLocales()

This function can be overridden by subclasses to use different heuristics It MUST return a 'safe' value, one whose modification will not affect this object.

protected NumberFormat
guessNumberFormat(int style)

This function can be overridden by subclasses to use different heuristics.

protected String
guessTerritory()

This function can be overridden by subclasses to use different heuristics.

protected TimeZone
guessTimeZone()

This function can be overridden by subclasses to use different heuristics.

private boolean
isAvailableLocale(ULocale loc, int type)

public boolean
isFrozen()

Implements com.ibm.icu.util.Freezable.isFrozen.

Determines whether the object has been frozen or not.
protected List<ULocale>
processLocales(List<ULocale>
The list of input locales
inputLocales
)

Process a language/locale priority list specified via setLocales.

public GlobalizationPreferences

Returns:

this, for chaining
reset
()

Restore the object to the initial state.

public GlobalizationPreferences

Returns:

this, for chaining
setBreakIterator
(int
break type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE
type
,
BreakIterator
a break iterator
iterator
)

Explicitly set the break iterator for this object.

public GlobalizationPreferences

Returns:

this, for chaining
setCalendar
(Calendar
arbitrary calendar
calendar
)

Sets the calendar.

public GlobalizationPreferences

Returns:

this, for chaining
setCollator
(Collator
The collator object to be passed.
collator
)

Explicitly set the collator for this object.

public GlobalizationPreferences

Returns:

this, for chaining
setCurrency
(Currency
Valid ISO 4217 currency code.
currency
)

Sets the currency code.

public GlobalizationPreferences

Returns:

this, for chaining
setDateFormat
(int
DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE
dateStyle
,
int
DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE
timeStyle
,
DateFormat
The date format
format
)

Set an explicit date format.

public GlobalizationPreferences

Returns:

this, for chaining
setLocale
(ULocale
single locale
uLocale
)

Convenience routine for setting the language/locale priority list from a single locale/language.

public GlobalizationPreferences

Returns:

this, for chaining
setLocales
(List<ULocale>
list of locales in priority order, eg {"be", "fr"} for Breton first, then French if that fails.
inputLocales
)

Sets the language/locale priority list.

public GlobalizationPreferences

Returns:

this, for chaining
setLocales
(ULocale[]
list of locales in an array
uLocales
)

Convenience routine for setting the language/locale priority list from an array.

public GlobalizationPreferences

Returns:

this, for chaining
setLocales
(String
Accept-Language list, as defined by Section 14.4 of the RFC 2616 (HTTP 1.1)
acceptLanguageString
)

Convenience routine for setting the locale priority list from an Accept-Language string.

public GlobalizationPreferences

Returns:

this, for chaining
setNumberFormat
(int
NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER
style
,
NumberFormat
The number format
format
)

Sets a number format explicitly.

public GlobalizationPreferences

Returns:

this, for chaining
setTerritory
(String
code
territory
)

Sets the territory, which is a valid territory according to for RFC 3066 (or successor).

public GlobalizationPreferences

Returns:

this, for chaining
setTimeZone
(TimeZone
a valid TZID (see UTS#35).
timezone
)

Sets the timezone ID. If this has not been set, uses default for territory.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

available_localesback to summary
private static final HashMap<ULocale, BitSet> available_locales
BI_CHARACTERback to summary
public static final int BI_CHARACTER

Break iterator type

ICU Status
Draft since ICU 3.6.
BI_LIMITback to summary
private static final int BI_LIMIT
BI_LINEback to summary
public static final int BI_LINE

Break iterator type

ICU Status
Draft since ICU 3.6.
BI_SENTENCEback to summary
public static final int BI_SENTENCE

Break iterator type

ICU Status
Draft since ICU 3.6.
BI_TITLEback to summary
public static final int BI_TITLE

Break iterator type

ICU Status
Draft since ICU 3.6.
BI_WORDback to summary
public static final int BI_WORD

Break iterator type

ICU Status
Draft since ICU 3.6.
breakIteratorsback to summary
private BreakIterator[] breakIterators
calendarback to summary
private Calendar calendar
collatorback to summary
private Collator collator
currencyback to summary
private Currency currency
dateFormatsback to summary
private DateFormat[][] dateFormats
DF_FULLback to summary
public static final int DF_FULL

Date Format type

ICU Status
Draft since ICU 3.6.
DF_LIMITback to summary
private static final int DF_LIMIT
DF_LONGback to summary
public static final int DF_LONG

Date Format type

ICU Status
Draft since ICU 3.6.
DF_MEDIUMback to summary
public static final int DF_MEDIUM

Date Format type

ICU Status
Draft since ICU 3.6.
DF_NONEback to summary
public static final int DF_NONE

Date Format type

ICU Status
Draft since ICU 3.6.
DF_SHORTback to summary
public static final int DF_SHORT

Date Format type

ICU Status
Draft since ICU 3.6.
frozenback to summary
private volatile boolean frozen
ID_CURRENCYback to summary
public static final int ID_CURRENCY

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
ID_CURRENCY_SYMBOLback to summary
public static final int ID_CURRENCY_SYMBOL

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
ID_KEYWORDback to summary
public static final int ID_KEYWORD

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
ID_KEYWORD_VALUEback to summary
public static final int ID_KEYWORD_VALUE

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
ID_LANGUAGEback to summary
public static final int ID_LANGUAGE

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
ID_LOCALEback to summary
public static final int ID_LOCALE

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
ID_SCRIPTback to summary
public static final int ID_SCRIPT

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
ID_TERRITORYback to summary
public static final int ID_TERRITORY

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
ID_TIMEZONEback to summary
public static final int ID_TIMEZONE

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
ID_VARIANTback to summary
public static final int ID_VARIANT

For selecting a choice of display names

ICU Status
Draft since ICU 3.6.
implicitLocalesback to summary
private List<ULocale> implicitLocales
language_territory_hackback to summary
private static final String[][] language_territory_hack
language_territory_hack_mapback to summary
private static final Map<String, String> language_territory_hack_map

Warning

All of this data is temporary, until we start importing from CLDR!!!

localesback to summary
private List<ULocale> locales
NF_CURRENCYback to summary
public static final int NF_CURRENCY

Number Format type

ICU Status
Draft since ICU 3.6.
NF_INTEGERback to summary
public static final int NF_INTEGER

Number Format type

ICU Status
Draft since ICU 3.6.
NF_LIMITback to summary
private static final int NF_LIMIT
NF_NUMBERback to summary
public static final int NF_NUMBER

Number Format type

ICU Status
Draft since ICU 3.6.
NF_PERCENTback to summary
public static final int NF_PERCENT

Number Format type

ICU Status
Draft since ICU 3.6.
NF_SCIENTIFICback to summary
public static final int NF_SCIENTIFIC

Number Format type

ICU Status
Draft since ICU 3.6.
numberFormatsback to summary
private NumberFormat[] numberFormats
territoryback to summary
private String territory
territory_tzid_hackback to summary
pack-priv static final String[][] territory_tzid_hack
territory_tzid_hack_mapback to summary
pack-priv static final Map<String, String> territory_tzid_hack_map
timezoneback to summary
private TimeZone timezone
TYPE_BREAKITERATORback to summary
private static final int TYPE_BREAKITERATOR
TYPE_CALENDARback to summary
private static final int TYPE_CALENDAR
TYPE_COLLATORback to summary
private static final int TYPE_COLLATOR
TYPE_DATEFORMATback to summary
private static final int TYPE_DATEFORMAT
TYPE_GENERICback to summary
private static final int TYPE_GENERIC
TYPE_LIMITback to summary
private static final int TYPE_LIMIT
TYPE_NUMBERFORMATback to summary
private static final int TYPE_NUMBERFORMAT

Constructor Detail

GlobalizationPreferencesback to summary
public GlobalizationPreferences()

Default constructor

ICU Status
Draft since ICU 3.6.

Method Detail

cloneAsThawedback to summary
public GlobalizationPreferences cloneAsThawed()

Implements com.ibm.icu.util.Freezable.cloneAsThawed.

Doc from com.ibm.icu.util.Freezable.cloneAsThawed.

Provides for the clone operation. Any clone is initially unfrozen.

Annotations
@Override
ICU Status
Draft since ICU 4.4.
freezeback to summary
public GlobalizationPreferences freeze()

Implements com.ibm.icu.util.Freezable.freeze.

Doc from com.ibm.icu.util.Freezable.freeze.

Freezes the object.

Returns:GlobalizationPreferences

the object itself.

Annotations
@Override
ICU Status
Draft since ICU 4.4.
getAvailableLocaleback to summary
private ULocale getAvailableLocale(int type)
getBreakIteratorback to summary
public BreakIterator getBreakIterator(int type)

Get a copy of the break iterator for the specified type according to the settings.

Parameters
type:int

break type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE

Returns:BreakIterator

break iterator explicit or implicit

ICU Status
Draft since ICU 3.6.
getCalendarback to summary
public Calendar getCalendar()

Get a copy of the calendar according to the settings.

Returns:Calendar

calendar explicit or implicit.

ICU Status
Draft since ICU 3.6.
getCollatorback to summary
public Collator getCollator()

Get a copy of the collator according to the settings.

Returns:Collator

collator explicit or implicit.

ICU Status
Draft since ICU 3.6.
getCurrencyback to summary
public Currency getCurrency()

Get a copy of the currency computed according to the settings.

Returns:Currency

currency code, explicit or implicit.

ICU Status
Draft since ICU 3.6.
getDateFormatback to summary
public DateFormat getDateFormat(int dateStyle, int timeStyle)

Gets a date format according to the current settings. If there is an explicit (non-null) date/time format set, a copy of that is returned. Otherwise, the language priority list is used. DF_NONE should be used for the style, where only the date or time format individually is being gotten.

Parameters
dateStyle:int

DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE

timeStyle:int

DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE

Returns:DateFormat

a DateFormat, according to the above description

ICU Status
Draft since ICU 3.6.
getDisplayNameback to summary
public String getDisplayName(String id, int type)

Get the display name for an ID: language, script, territory, currency, timezone... Uses the language priority list to do so.

Parameters
id:String

language code, script code, ...

type:int

specifies the type of the ID: ID_LANGUAGE, etc.

Returns:String

the display name

ICU Status
Draft since ICU 3.6.
getLocaleback to summary
public ULocale getLocale(int index)

Convenience function for getting the locales in priority order

Parameters
index:int

The index (0..n) of the desired item.

Returns:ULocale

desired item. null if index is out of range

ICU Status
Draft since ICU 3.6.
getLocalesback to summary
public List<ULocale> getLocales()

Get a copy of the language/locale priority list

Returns:List<ULocale>

a copy of the language/locale priority list.

ICU Status
Draft since ICU 3.6.
getNumberFormatback to summary
public NumberFormat getNumberFormat(int style)

Gets a number format according to the current settings. If there is an explicit (non-null) number format set, a copy of that is returned. Otherwise, the language priority list is used.

Parameters
style:int

NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER

ICU Status
Draft since ICU 3.6.
getResourceBundleback to summary
public ResourceBundle getResourceBundle(String baseName)

Convenience function to get a ResourceBundle instance using the specified base name based on the language/locale priority list stored in this object.

Parameters
baseName:String

the base name of the resource bundle, a fully qualified class name

Returns:ResourceBundle

a resource bundle for the given base name and locale based on the language/locale priority list stored in this object

ICU Status
Draft since ICU 3.6.
getResourceBundleback to summary
public ResourceBundle getResourceBundle(String baseName, ClassLoader loader)

Convenience function to get a ResourceBundle instance using the specified base name and class loader based on the language/locale priority list stored in this object.

Parameters
baseName:String

the base name of the resource bundle, a fully qualified class name

loader:ClassLoader

the class object from which to load the resource bundle

Returns:ResourceBundle

a resource bundle for the given base name and locale based on the language/locale priority list stored in this object

ICU Status
Draft since ICU 3.6.
getTerritoryback to summary
public String getTerritory()

Gets the territory setting. If it wasn't explicitly set, it is computed from the general locale setting.

Returns:String

territory code, explicit or implicit.

ICU Status
Draft since ICU 3.6.
getTimeZoneback to summary
public TimeZone getTimeZone()

Get the timezone. It was either explicitly set, or is heuristically computed from other settings.

Returns:TimeZone

timezone, either implicitly or explicitly set

ICU Status
Draft since ICU 3.6.
guessBreakIteratorback to summary
protected BreakIterator guessBreakIterator(int type)

This function can be overridden by subclasses to use different heuristics. It MUST return a 'safe' value, one whose modification will not affect this object.

ICU Status
Draft since ICU 3.6.
guessCalendarback to summary
protected Calendar guessCalendar()

This function can be overridden by subclasses to use different heuristics. It MUST return a 'safe' value, one whose modification will not affect this object.

ICU Status
Draft since ICU 3.6.
guessCollatorback to summary
protected Collator guessCollator()

This function can be overridden by subclasses to use different heuristics. It MUST return a 'safe' value, one whose modification will not affect this object.

ICU Status
Draft since ICU 3.6.
guessCurrencyback to summary
protected Currency guessCurrency()

This function can be overridden by subclasses to use different heuristics

ICU Status
Draft since ICU 3.6.
guessDateFormatback to summary
protected DateFormat guessDateFormat(int dateStyle, int timeStyle)

This function can be overridden by subclasses to use different heuristics. It MUST return a 'safe' value, one whose modification will not affect this object.

ICU Status
Draft since ICU 3.6.
guessLocalesback to summary
protected List<ULocale> guessLocales()

This function can be overridden by subclasses to use different heuristics It MUST return a 'safe' value, one whose modification will not affect this object.

ICU Status
Draft since ICU 3.6.
guessNumberFormatback to summary
protected NumberFormat guessNumberFormat(int style)

This function can be overridden by subclasses to use different heuristics. It MUST return a 'safe' value, one whose modification will not affect this object.

ICU Status
Draft since ICU 3.6.
guessTerritoryback to summary
protected String guessTerritory()

This function can be overridden by subclasses to use different heuristics.

ICU Status
Draft since ICU 3.6.
guessTimeZoneback to summary
protected TimeZone guessTimeZone()

This function can be overridden by subclasses to use different heuristics. It MUST return a 'safe' value, one whose modification will not affect this object.

ICU Status
Draft since ICU 3.6.
isAvailableLocaleback to summary
private boolean isAvailableLocale(ULocale loc, int type)
isFrozenback to summary
public boolean isFrozen()

Implements com.ibm.icu.util.Freezable.isFrozen.

Doc from com.ibm.icu.util.Freezable.isFrozen.

Determines whether the object has been frozen or not.

Annotations
@Override
ICU Status
Draft since ICU 3.6.
processLocalesback to summary
protected List<ULocale> processLocales(List<ULocale> inputLocales)

Process a language/locale priority list specified via setLocales. The input locale list may be expanded or re-ordered to represent the prioritized language/locale order actually used by this object by the algorithm explained below.

Step 1: Move later occurrence of more specific locale before earlier occurrence of less specific locale.
Before: en, fr_FR, en_US, en_GB
After: en_US, en_GB, en, fr_FR

Step 2: Append a fallback locale to each locale.
Before: en_US, en_GB, en, fr_FR
After: en_US, en, en_GB, en, en, fr_FR, fr

Step 3: Remove earlier occurrence of duplicated locale entries.
Before: en_US, en, en_GB, en, en, fr_FR, fr
After: en_US, en_GB, en, fr_FR, fr

The final locale list is used to produce a default value for the appropriate territory, currency, timezone, etc. The list also represents the lookup order used in getResourceBundle for this object. A subclass may override this method to customize the algorithm used for populating the locale list.

Parameters
inputLocales:List<ULocale>

The list of input locales

ICU Status
Draft since ICU 3.6.
resetback to summary
public GlobalizationPreferences reset()

Restore the object to the initial state.

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
setBreakIteratorback to summary
public GlobalizationPreferences setBreakIterator(int type, BreakIterator iterator)

Explicitly set the break iterator for this object.

Parameters
type:int

break type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE

iterator:BreakIterator

a break iterator

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
setCalendarback to summary
public GlobalizationPreferences setCalendar(Calendar calendar)

Sets the calendar. If this has not been set, uses default for territory.

Parameters
calendar:Calendar

arbitrary calendar

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
setCollatorback to summary
public GlobalizationPreferences setCollator(Collator collator)

Explicitly set the collator for this object.

Parameters
collator:Collator

The collator object to be passed.

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
setCurrencyback to summary
public GlobalizationPreferences setCurrency(Currency currency)

Sets the currency code. If this has not been set, uses default for territory.

Parameters
currency:Currency

Valid ISO 4217 currency code.

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
setDateFormatback to summary
public GlobalizationPreferences setDateFormat(int dateStyle, int timeStyle, DateFormat format)

Set an explicit date format. Overrides the locale priority list for a particular combination of dateStyle and timeStyle. DF_NONE should be used if for the style, where only the date or time format individually is being set.

Parameters
dateStyle:int

DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE

timeStyle:int

DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE

format:DateFormat

The date format

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
setLocaleback to summary
public GlobalizationPreferences setLocale(ULocale uLocale)

Convenience routine for setting the language/locale priority list from a single locale/language.

Parameters
uLocale:ULocale

single locale

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
See Also
setLocales(List locales)
setLocalesback to summary
public GlobalizationPreferences setLocales(List<ULocale> inputLocales)

Sets the language/locale priority list. If other information is not (yet) available, this is used to to produce a default value for the appropriate territory, currency, timezone, etc. The user should be given the opportunity to correct those defaults in case they are incorrect.

Parameters
inputLocales:List<ULocale>

list of locales in priority order, eg {"be", "fr"} for Breton first, then French if that fails.

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
setLocalesback to summary
public GlobalizationPreferences setLocales(ULocale[] uLocales)

Convenience routine for setting the language/locale priority list from an array.

Parameters
uLocales:ULocale[]

list of locales in an array

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
See Also
setLocales(List locales)
setLocalesback to summary
public GlobalizationPreferences setLocales(String acceptLanguageString)

Convenience routine for setting the locale priority list from an Accept-Language string.

Parameters
acceptLanguageString:String

Accept-Language list, as defined by Section 14.4 of the RFC 2616 (HTTP 1.1)

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
See Also
setLocales(List locales)
setNumberFormatback to summary
public GlobalizationPreferences setNumberFormat(int style, NumberFormat format)

Sets a number format explicitly. Overrides the general locale settings.

Parameters
style:int

NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER

format:NumberFormat

The number format

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
setTerritoryback to summary
public GlobalizationPreferences setTerritory(String territory)

Sets the territory, which is a valid territory according to for RFC 3066 (or successor). If not otherwise set, default currency and timezone values will be set from this. The user should be given the opportunity to correct those defaults in case they are incorrect.

Parameters
territory:String

code

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.
setTimeZoneback to summary
public GlobalizationPreferences setTimeZone(TimeZone timezone)

Sets the timezone ID. If this has not been set, uses default for territory.

Parameters
timezone:TimeZone

a valid TZID (see UTS#35).

Returns:GlobalizationPreferences

this, for chaining

ICU Status
Draft since ICU 3.6.