DecimalFormatSymbols

public class DecimalFormatSymbols extends Object
implements Cloneable Serializable

[icu enhancement] ICU's replacement for DecimalFormatSymbols. Methods, fields, and other functionality specific to ICU are labeled '[icu]'. This class represents the set of symbols (such as the decimal separator, the grouping separator, and so on) needed by DecimalFormat to format numbers. DecimalFormat creates for itself an instance of DecimalFormatSymbols from its locale data. If you need to change any of these symbols, you can get the DecimalFormatSymbols object from your DecimalFormat and modify it.

Constant Summary

int CURRENCY_SPC_CURRENCY_MATCH [icu] Indicates the currency match pattern used in getPatternForCurrencySpacing(int, boolean).
int CURRENCY_SPC_INSERT [icu] Indicates the insertion value used in getPatternForCurrencySpacing(int, boolean).
int CURRENCY_SPC_SURROUNDING_MATCH [icu] Indicates the surrounding match pattern used in getPatternForCurrencySpacing(int, boolean).

Public Constructor Summary

DecimalFormatSymbols()
Creates a DecimalFormatSymbols object for the default FORMAT locale.
DecimalFormatSymbols(Locale locale)
Creates a DecimalFormatSymbols object for the given locale.
DecimalFormatSymbols(ULocale locale)
[icu] Creates a DecimalFormatSymbols object for the given locale.

Public Method Summary

Object
clone()
Creates and returns a copy of this Object.
boolean
equals(Object obj)
Compares this instance with the specified object and indicates if they are equal.
static Locale[]
getAvailableLocales()
Returns an array of all locales for which the getInstance methods of this class can return localized instances.
Currency
getCurrency()
Returns the currency symbol, for getCurrency() API compatibility only.
String
getCurrencySymbol()
Returns the string denoting the local currency.
char
getDecimalSeparator()
Returns the character used for decimal sign.
char
getDigit()
Returns the character used for a digit in a pattern.
char[]
getDigits()
Returns the array of characters used as digits, in order from 0 through 9
String
getExponentMultiplicationSign()
Returns the multiplication sign
String
getExponentSeparator()
[icu] Returns the string used to separate the mantissa from the exponent.
char
getGroupingSeparator()
Returns the character used for grouping separator.
String
getInfinity()
Returns the String used to represent infinity.
static DecimalFormatSymbols
getInstance()
Returns a DecimalFormatSymbols instance for the default locale.
static DecimalFormatSymbols
getInstance(Locale locale)
Returns a DecimalFormatSymbols instance for the given locale.
static DecimalFormatSymbols
getInstance(ULocale locale)
Returns a DecimalFormatSymbols instance for the given locale.
String
getInternationalCurrencySymbol()
Returns the international string denoting the local currency.
Locale
getLocale()
Returns the locale for which this object was constructed.
char
getMinusSign()
Returns the character used to represent minus sign.
char
getMonetaryDecimalSeparator()
Returns the monetary decimal separator.
char
getMonetaryGroupingSeparator()
[icu] Returns the monetary grouping separator.
String
getNaN()
Returns the String used to represent NaN.
char
getPadEscape()
[icu] Returns the character used to pad numbers out to a specified width.
String
getPatternForCurrencySpacing(int itemType, boolean beforeCurrency)
[icu] Returns the desired currency spacing value.
char
getPatternSeparator()
Returns the character used to separate positive and negative subpatterns in a pattern.
char
getPerMill()
Returns the character used for mille percent sign.
char
getPercent()
Returns the character used for percent sign.
char
getPlusSign()
[icu] Returns the localized plus sign.
char
getSignificantDigit()
Returns the character used to represent a significant digit in a pattern.
ULocale
getULocale()
Returns the locale for which this object was constructed.
char
getZeroDigit()
Returns the character used for zero.
int
hashCode()
Returns an integer hash code for this object.
void
setCurrency(Currency currency)
Sets the currency.
void
setCurrencySymbol(String currency)
Sets the string denoting the local currency.
void
setDecimalSeparator(char decimalSeparator)
Sets the character used for decimal sign.
void
setDigit(char digit)
Sets the character used for a digit in a pattern.
void
setExponentMultiplicationSign(String exponentMultiplicationSign)
Sets the multiplication sign
void
setExponentSeparator(String exp)
[icu] Sets the string used to separate the mantissa from the exponent.
void
setGroupingSeparator(char groupingSeparator)
Sets the character used for grouping separator.
void
setInfinity(String infinity)
Sets the String used to represent infinity.
void
setInternationalCurrencySymbol(String currency)
Sets the international string denoting the local currency.
void
setMinusSign(char minusSign)
Sets the character used to represent minus sign.
void
setMonetaryDecimalSeparator(char sep)
Sets the monetary decimal separator.
void
setMonetaryGroupingSeparator(char sep)
[icu] Sets the monetary grouping separator.
void
setNaN(String NaN)
Sets the String used to represent NaN.
void
setPadEscape(char c)
[icu] Sets the character used to pad numbers out to a specified width.
void
setPatternForCurrencySpacing(int itemType, boolean beforeCurrency, String pattern)
[icu] Sets the indicated currency spacing pattern or value.
void
setPatternSeparator(char patternSeparator)
Sets the character used to separate positive and negative subpatterns in a pattern.
void
setPerMill(char perMill)
Sets the character used for mille percent sign.
void
setPercent(char percent)
Sets the character used for percent sign.
void
setPlusSign(char plus)
[icu] Sets the localized plus sign.
void
setSignificantDigit(char sigDigit)
Sets the character used to represent a significant digit in a pattern.
void
setZeroDigit(char zeroDigit)
Sets the character used for zero.

Inherited Method Summary

Constants

public static final int CURRENCY_SPC_CURRENCY_MATCH

[icu] Indicates the currency match pattern used in getPatternForCurrencySpacing(int, boolean).

Constant Value: 0

public static final int CURRENCY_SPC_INSERT

[icu] Indicates the insertion value used in getPatternForCurrencySpacing(int, boolean).

Constant Value: 2

public static final int CURRENCY_SPC_SURROUNDING_MATCH

[icu] Indicates the surrounding match pattern used in getPatternForCurrencySpacing(int, boolean).

Constant Value: 1

Public Constructors

public DecimalFormatSymbols ()

Creates a DecimalFormatSymbols object for the default FORMAT locale.

See Also

public DecimalFormatSymbols (Locale locale)

Creates a DecimalFormatSymbols object for the given locale.

Parameters
locale the locale

public DecimalFormatSymbols (ULocale locale)

[icu] Creates a DecimalFormatSymbols object for the given locale.

Parameters
locale the locale

Public Methods

public Object clone ()

Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.

Returns
  • a copy of this object.

public boolean equals (Object obj)

Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.

The default implementation returns true only if this == o. See Writing a correct equals method if you intend implementing your own equals method.

The general contract for the equals and hashCode() methods is that if equals returns true for any two objects, then hashCode() must return the same value for these objects. This means that subclasses of Object usually override either both methods or neither of them.

Parameters
obj the object to compare this instance with.
Returns
  • true if the specified object is equal to this Object; false otherwise.

public static Locale[] getAvailableLocales ()

Returns an array of all locales for which the getInstance methods of this class can return localized instances.

Note: Unlike java.text.DecimalFormatSymbols#getAvailableLocales, this method simply returns the array of Locales available for this class. ICU currently does not support DecimalFormatSymbolsProvider, which was introduced in Java 6.

Returns
  • An array of Locales for which localized DecimalFormatSymbols instances are available.

public Currency getCurrency ()

Returns the currency symbol, for getCurrency() API compatibility only. ICU clients should use the Currency API directly.

Returns
  • the currency used, or null

public String getCurrencySymbol ()

Returns the string denoting the local currency.

Returns
  • the local currency String.

public char getDecimalSeparator ()

Returns the character used for decimal sign. Different for French, etc.

Returns
  • the decimal character

public char getDigit ()

Returns the character used for a digit in a pattern.

Returns
  • the digit pattern character

public char[] getDigits ()

Returns the array of characters used as digits, in order from 0 through 9

Returns
  • The array

public String getExponentMultiplicationSign ()

Returns the multiplication sign

public String getExponentSeparator ()

[icu] Returns the string used to separate the mantissa from the exponent. Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.

Returns
  • the localized exponent symbol, used in localized patterns and formatted strings

public char getGroupingSeparator ()

Returns the character used for grouping separator. Different for French, etc.

Returns
  • the thousands character

public String getInfinity ()

Returns the String used to represent infinity. Almost always left unchanged.

Returns
  • the Infinity string

public static DecimalFormatSymbols getInstance ()

Returns a DecimalFormatSymbols instance for the default locale.

Note: Unlike java.text.DecimalFormatSymbols#getInstance, this method simply returns new android.icu.text.DecimalFormatSymbols(). ICU currently does not support DecimalFormatSymbolsProvider, which was introduced in Java 6.

Returns
  • A DecimalFormatSymbols instance.

public static DecimalFormatSymbols getInstance (Locale locale)

Returns a DecimalFormatSymbols instance for the given locale.

Note: Unlike java.text.DecimalFormatSymbols#getInstance, this method simply returns new android.icu.text.DecimalFormatSymbols(locale). ICU currently does not support DecimalFormatSymbolsProvider, which was introduced in Java 6.

Parameters
locale the locale.
Returns
  • A DecimalFormatSymbols instance.

public static DecimalFormatSymbols getInstance (ULocale locale)

Returns a DecimalFormatSymbols instance for the given locale.

Note: Unlike java.text.DecimalFormatSymbols#getInstance, this method simply returns new android.icu.text.DecimalFormatSymbols(locale). ICU currently does not support DecimalFormatSymbolsProvider, which was introduced in Java 6.

Parameters
locale the locale.
Returns
  • A DecimalFormatSymbols instance.

public String getInternationalCurrencySymbol ()

Returns the international string denoting the local currency.

Returns
  • the international string denoting the local currency

public Locale getLocale ()

Returns the locale for which this object was constructed.

Returns
  • the locale for which this object was constructed

public char getMinusSign ()

Returns the character used to represent minus sign. If no explicit negative format is specified, one is formed by prefixing minusSign to the positive format.

Returns
  • the minus sign character

public char getMonetaryDecimalSeparator ()

Returns the monetary decimal separator.

Returns
  • the monetary decimal separator character

public char getMonetaryGroupingSeparator ()

[icu] Returns the monetary grouping separator.

Returns
  • the monetary grouping separator character

public String getNaN ()

Returns the String used to represent NaN. Almost always left unchanged.

Returns
  • the NaN String

public char getPadEscape ()

[icu] Returns the character used to pad numbers out to a specified width. This is not the pad character itself; rather, it is the special pattern character preceding the pad character. In the pattern "*_#,##0", '*' is the pad escape, and '_' is the pad character.

Returns
  • the character

public String getPatternForCurrencySpacing (int itemType, boolean beforeCurrency)

[icu] Returns the desired currency spacing value. Original values come from ICU's CLDR data based on the locale provided during construction, and can be null. These values govern what and when text is inserted between a currency code/name/symbol and the currency amount when formatting money.

For more information, see UTS#35 section 5.10.2.

Note: ICU4J does not currently use this information.

Parameters
itemType one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH or CURRENCY_SPC_INSERT
beforeCurrency true to get the beforeCurrency values, false to get the afterCurrency values.
Returns
  • the value, or null.

public char getPatternSeparator ()

Returns the character used to separate positive and negative subpatterns in a pattern.

Returns
  • the pattern separator character

public char getPerMill ()

Returns the character used for mille percent sign. Different for Arabic, etc.

Returns
  • the mille percent character

public char getPercent ()

Returns the character used for percent sign. Different for Arabic, etc.

Returns
  • the percent character

public char getPlusSign ()

[icu] Returns the localized plus sign.

Returns
  • the plus sign, used in localized patterns and formatted strings

public char getSignificantDigit ()

Returns the character used to represent a significant digit in a pattern.

Returns
  • the significant digit pattern character

public ULocale getULocale ()

Returns the locale for which this object was constructed.

Returns
  • the locale for which this object was constructed

public char getZeroDigit ()

Returns the character used for zero. Different for Arabic, etc.

Returns
  • the character

public int hashCode ()

Returns an integer hash code for this object. By contract, any two objects for which equals(Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

Note that hash values must not change over time unless information used in equals comparisons also changes.

See Writing a correct hashCode method if you intend implementing your own hashCode method.

Returns
  • this object's hash code.

public void setCurrency (Currency currency)

Sets the currency.

Note: ICU does not use the DecimalFormatSymbols for the currency any more. This API is present for API compatibility only.

This also sets the currency symbol attribute to the currency's symbol in the DecimalFormatSymbols' locale, and the international currency symbol attribute to the currency's ISO 4217 currency code.

Parameters
currency the new currency to be used
Throws
NullPointerException if currency is null

public void setCurrencySymbol (String currency)

Sets the string denoting the local currency.

Parameters
currency the local currency String.

public void setDecimalSeparator (char decimalSeparator)

Sets the character used for decimal sign. Different for French, etc.

Parameters
decimalSeparator the decimal character

public void setDigit (char digit)

Sets the character used for a digit in a pattern.

Parameters
digit the digit pattern character

public void setExponentMultiplicationSign (String exponentMultiplicationSign)

Sets the multiplication sign

Parameters
exponentMultiplicationSign

public void setExponentSeparator (String exp)

[icu] Sets the string used to separate the mantissa from the exponent. Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.

Parameters
exp the localized exponent symbol, used in localized patterns and formatted strings

public void setGroupingSeparator (char groupingSeparator)

Sets the character used for grouping separator. Different for French, etc.

Parameters
groupingSeparator the thousands character

public void setInfinity (String infinity)

Sets the String used to represent infinity. Almost always left unchanged.

Parameters
infinity the Infinity String

public void setInternationalCurrencySymbol (String currency)

Sets the international string denoting the local currency.

Parameters
currency the international string denoting the local currency.

public void setMinusSign (char minusSign)

Sets the character used to represent minus sign. If no explicit negative format is specified, one is formed by prefixing minusSign to the positive format.

Parameters
minusSign the minus sign character

public void setMonetaryDecimalSeparator (char sep)

Sets the monetary decimal separator.

Parameters
sep the monetary decimal separator character

public void setMonetaryGroupingSeparator (char sep)

[icu] Sets the monetary grouping separator.

Parameters
sep the monetary grouping separator character

public void setNaN (String NaN)

Sets the String used to represent NaN. Almost always left unchanged.

Parameters
NaN the NaN String

public void setPadEscape (char c)

[icu] Sets the character used to pad numbers out to a specified width. This is not the pad character itself; rather, it is the special pattern character preceding the pad character. In the pattern "*_#,##0", '*' is the pad escape, and '_' is the pad character.

Parameters
c

public void setPatternForCurrencySpacing (int itemType, boolean beforeCurrency, String pattern)

[icu] Sets the indicated currency spacing pattern or value. See getPatternForCurrencySpacing(int, boolean) for more information.

Values for currency match and surrounding match must be UnicodeSet patterns. Values for insert can be any string.

Note: ICU4J does not currently use this information.

Parameters
itemType one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH or CURRENCY_SPC_INSERT
beforeCurrency true if the pattern is for before the currency symbol. false if the pattern is for after it.
pattern string to override current setting; can be null.

public void setPatternSeparator (char patternSeparator)

Sets the character used to separate positive and negative subpatterns in a pattern.

Parameters
patternSeparator the pattern separator character

public void setPerMill (char perMill)

Sets the character used for mille percent sign. Different for Arabic, etc.

Parameters
perMill the mille percent character

public void setPercent (char percent)

Sets the character used for percent sign. Different for Arabic, etc.

Parameters
percent the percent character

public void setPlusSign (char plus)

[icu] Sets the localized plus sign.

Parameters
plus the plus sign, used in localized patterns and formatted strings

public void setSignificantDigit (char sigDigit)

Sets the character used to represent a significant digit in a pattern.

Parameters
sigDigit the significant digit pattern character

public void setZeroDigit (char zeroDigit)

Sets the character used for zero.

Note: When the specified zeroDigit is a Unicode decimal digit character (category:Nd) and the number value is 0, then this method propagate digit 1 to digit 9 by incrementing code point one by one.

Parameters
zeroDigit the zero character.