Most visited

Recently visited

Added in API level 24

DecimalFormatSymbols

public class DecimalFormatSymbols
extends Object implements Cloneable, Serializable

java.lang.Object
   ↳ android.icu.text.DecimalFormatSymbols


[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.

See also:

Summary

Constants

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 constructors

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 methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

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 thousands 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 a hash code value for the 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 thousands 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)

Sets the monetary decimal 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 methods

From class java.lang.Object

Constants

CURRENCY_SPC_CURRENCY_MATCH

Added in API level 24
int CURRENCY_SPC_CURRENCY_MATCH

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

Constant Value: 0 (0x00000000)

CURRENCY_SPC_INSERT

Added in API level 24
int CURRENCY_SPC_INSERT

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

Constant Value: 2 (0x00000002)

CURRENCY_SPC_SURROUNDING_MATCH

Added in API level 24
int CURRENCY_SPC_SURROUNDING_MATCH

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

Constant Value: 1 (0x00000001)

Public constructors

DecimalFormatSymbols

Added in API level 24
DecimalFormatSymbols ()

Creates a DecimalFormatSymbols object for the default FORMAT locale.

See also:

DecimalFormatSymbols

Added in API level 24
DecimalFormatSymbols (Locale locale)

Creates a DecimalFormatSymbols object for the given locale.

Parameters
locale Locale: the locale

DecimalFormatSymbols

Added in API level 24
DecimalFormatSymbols (ULocale locale)

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

Parameters
locale ULocale: the locale

Public methods

clone

Added in API level 24
Object clone ()

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

 x.clone() != x
will be true, and that the expression:
 x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
 x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

The method clone for class Object performs a specific cloning operation. First, if the class of this object does not implement the interface Cloneable, then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable and that the return type of the clone method of an array type T[] is T[] where T is any reference or primitive type. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.

The class Object does not itself implement the interface Cloneable, so calling the clone method on an object whose class is Object will result in throwing an exception at run time.

Returns
Object a clone of this instance.

equals

Added in API level 24
boolean equals (Object obj)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
obj Object: the reference object with which to compare.
Returns
boolean true if this object is the same as the obj argument; false otherwise.

getAvailableLocales

Added in API level 24
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
Locale[] An array of Locales for which localized DecimalFormatSymbols instances are available.

getCurrency

Added in API level 24
Currency getCurrency ()

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

Returns
Currency the currency used, or null

getCurrencySymbol

Added in API level 24
String getCurrencySymbol ()

Returns the string denoting the local currency.

Returns
String the local currency String.

getDecimalSeparator

Added in API level 24
char getDecimalSeparator ()

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

Returns
char the decimal character

getDigit

Added in API level 24
char getDigit ()

Returns the character used for a digit in a pattern.

Returns
char the digit pattern character

getDigits

Added in API level 24
char[] getDigits ()

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

Returns
char[] The array

getExponentMultiplicationSign

Added in API level 24
String getExponentMultiplicationSign ()

Returns the multiplication sign

Returns
String

getExponentSeparator

Added in API level 24
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
String the localized exponent symbol, used in localized patterns and formatted strings

See also:

getGroupingSeparator

Added in API level 24
char getGroupingSeparator ()

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

Returns
char the thousands character

getInfinity

Added in API level 24
String getInfinity ()

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

Returns
String the Infinity string

getInstance

Added in API level 24
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
DecimalFormatSymbols A DecimalFormatSymbols instance.

getInstance

Added in API level 24
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 Locale: the locale.
Returns
DecimalFormatSymbols A DecimalFormatSymbols instance.

getInstance

Added in API level 24
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 ULocale: the locale.
Returns
DecimalFormatSymbols A DecimalFormatSymbols instance.

getInternationalCurrencySymbol

Added in API level 24
String getInternationalCurrencySymbol ()

Returns the international string denoting the local currency.

Returns
String the international string denoting the local currency

getLocale

Added in API level 24
Locale getLocale ()

Returns the locale for which this object was constructed.

Returns
Locale the locale for which this object was constructed

getMinusSign

Added in API level 24
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
char the minus sign character

getMonetaryDecimalSeparator

Added in API level 24
char getMonetaryDecimalSeparator ()

Returns the monetary decimal separator.

Returns
char the monetary decimal separator character

getMonetaryGroupingSeparator

Added in API level 24
char getMonetaryGroupingSeparator ()

[icu] Returns the monetary grouping separator.

Returns
char the monetary grouping separator character

getNaN

Added in API level 24
String getNaN ()

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

Returns
String the NaN String

getPadEscape

Added in API level 24
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
char the character

See also:

getPatternForCurrencySpacing

Added in API level 24
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 int: one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH or CURRENCY_SPC_INSERT
beforeCurrency boolean: true to get the beforeCurrency values, false to get the afterCurrency values.
Returns
String the value, or null.

See also:

getPatternSeparator

Added in API level 24
char getPatternSeparator ()

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

Returns
char the pattern separator character

getPerMill

Added in API level 24
char getPerMill ()

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

Returns
char the mille percent character

getPercent

Added in API level 24
char getPercent ()

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

Returns
char the percent character

getPlusSign

Added in API level 24
char getPlusSign ()

[icu] Returns the localized plus sign.

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

See also:

getSignificantDigit

Added in API level 24
char getSignificantDigit ()

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

Returns
char the significant digit pattern character

getULocale

Added in API level 24
ULocale getULocale ()

Returns the locale for which this object was constructed.

Returns
ULocale the locale for which this object was constructed

getZeroDigit

Added in API level 24
char getZeroDigit ()

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

Returns
char the character

hashCode

Added in API level 24
int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Returns
int a hash code value for this object.

setCurrency

Added in API level 24
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 Currency: the new currency to be used
Throws
NullPointerException if currency is null

See also:

setCurrencySymbol

Added in API level 24
void setCurrencySymbol (String currency)

Sets the string denoting the local currency.

Parameters
currency String: the local currency String.

setDecimalSeparator

Added in API level 24
void setDecimalSeparator (char decimalSeparator)

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

Parameters
decimalSeparator char: the decimal character

setDigit

Added in API level 24
void setDigit (char digit)

Sets the character used for a digit in a pattern.

Parameters
digit char: the digit pattern character

setExponentMultiplicationSign

Added in API level 24
void setExponentMultiplicationSign (String exponentMultiplicationSign)

Sets the multiplication sign

Parameters
exponentMultiplicationSign String

setExponentSeparator

Added in API level 24
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 String: the localized exponent symbol, used in localized patterns and formatted strings

See also:

setGroupingSeparator

Added in API level 24
void setGroupingSeparator (char groupingSeparator)

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

Parameters
groupingSeparator char: the thousands character

setInfinity

Added in API level 24
void setInfinity (String infinity)

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

Parameters
infinity String: the Infinity String

setInternationalCurrencySymbol

Added in API level 24
void setInternationalCurrencySymbol (String currency)

Sets the international string denoting the local currency.

Parameters
currency String: the international string denoting the local currency.

setMinusSign

Added in API level 24
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 char: the minus sign character

setMonetaryDecimalSeparator

Added in API level 24
void setMonetaryDecimalSeparator (char sep)

Sets the monetary decimal separator.

Parameters
sep char: the monetary decimal separator character

setMonetaryGroupingSeparator

Added in API level 24
void setMonetaryGroupingSeparator (char sep)

Sets the monetary decimal separator.

Parameters
sep char: the monetary decimal separator character

setNaN

Added in API level 24
void setNaN (String NaN)

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

Parameters
NaN String: the NaN String

setPadEscape

Added in API level 24
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 char

See also:

setPatternForCurrencySpacing

Added in API level 24
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 int: one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH or CURRENCY_SPC_INSERT
beforeCurrency boolean: true if the pattern is for before the currency symbol. false if the pattern is for after it.
pattern String: string to override current setting; can be null.

See also:

setPatternSeparator

Added in API level 24
void setPatternSeparator (char patternSeparator)

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

Parameters
patternSeparator char: the pattern separator character

setPerMill

Added in API level 24
void setPerMill (char perMill)

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

Parameters
perMill char: the mille percent character

setPercent

Added in API level 24
void setPercent (char percent)

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

Parameters
percent char: the percent character

setPlusSign

Added in API level 24
void setPlusSign (char plus)

[icu] Sets the localized plus sign.

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

See also:

setSignificantDigit

Added in API level 24
void setSignificantDigit (char sigDigit)

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

Parameters
sigDigit char: the significant digit pattern character

setZeroDigit

Added in API level 24
void setZeroDigit (char zeroDigit)

Sets the character used for zero.

Parameters
zeroDigit char: the zero character.

Hooray!