Class DecimalFormatSymbols
- All Implemented Interfaces:
Serializable, Cloneable
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates the currency match pattern used ingetPatternForCurrencySpacing(int, boolean).static final intIndicates the insertion value used ingetPatternForCurrencySpacing(int, boolean).static final intIndicates the surrounding match pattern used ingetPatternForCurrencySpacing(int, boolean). -
Constructor Summary
ConstructorsConstructorDescriptionCreates a DecimalFormatSymbols object for the defaultFORMATlocale.DecimalFormatSymbols(Locale locale) Creates a DecimalFormatSymbols object for the given locale.DecimalFormatSymbols(ULocale locale) Creates a DecimalFormatSymbols object for the given locale. -
Method Summary
Modifier and TypeMethodDescriptionclone()booleanstatic DecimalFormatSymbolsforNumberingSystem(Locale locale, NumberingSystem ns) Returns a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the givenNumberingSystem.static DecimalFormatSymbolsforNumberingSystem(ULocale locale, NumberingSystem ns) Returns a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the givenNumberingSystem.Deprecated.This API is for technology preview only.static Locale[]Returns an array of all locales for which thegetInstancemethods of this class can return localized instances.static ULocale[]Returns an array of all locales for which thegetInstancemethods of this class can return localized instances.intDeprecated.This API is ICU internal only.Returns the currency symbol, forgetCurrency()API compatibility only.Deprecated.This API is for ICU internal use onlyReturns the string denoting the local currency.charReturns the character used for decimal sign.Returns the string used for decimal sign.chargetDigit()Returns the character used for a digit in a pattern.char[]Returns the array of characters used as digits, in order from 0 through 9String[]Returns the array of strings used as digits, in order from 0 through 9String[]Deprecated.This API is ICU internal only.Returns the multiplication signReturns the string used to separate the mantissa from the exponent.charReturns the character used for grouping separator.Returns the string used for grouping separator.Returns the String used to represent infinity.static DecimalFormatSymbolsReturns a DecimalFormatSymbols instance for the default locale.static DecimalFormatSymbolsgetInstance(Locale locale) Returns a DecimalFormatSymbols instance for the given locale.static DecimalFormatSymbolsgetInstance(ULocale locale) Returns a DecimalFormatSymbols instance for the given locale.Returns the international string denoting the local currency.Returns the locale for which this object was constructed.final ULocalegetLocale(ULocale.Type type) Returns the locale that was used to create this object, or null.charReturns the character used to represent minus sign.Returns the string used to represent minus sign.charReturns the monetary decimal separator.Returns the monetary decimal separator string.charReturns the monetary grouping separator.Returns the monetary grouping separator.getNaN()Returns the String used to represent NaN.charReturns the character used to pad numbers out to a specified width.getPatternForCurrencySpacing(int itemType, boolean beforeCurrency) Returns the desired currency spacing value.charReturns the character used to separate positive and negative subpatterns in a pattern.charReturns the character used for percent sign.Returns the string used for percent sign.charReturns the character used for mille percent sign.Returns the string used for permille sign.charReturns the localized plus sign.Returns the string used to represent plus sign.charReturns the character used to represent a significant digit in a pattern.Returns the locale for which this object was constructed.charReturns the character used for zero.inthashCode()voidsetApproximatelySignString(String approximatelySignString) Deprecated.This API is for technology preview only.voidsetCurrency(Currency currency) Sets the currency.voidsetCurrencySymbol(String currency) Sets the string denoting the local currency.voidsetDecimalSeparator(char decimalSeparator) Sets the character used for decimal sign.voidsetDecimalSeparatorString(String decimalSeparatorString) Sets the string used for decimal sign.voidsetDigit(char digit) Sets the character used for a digit in a pattern.voidsetDigitStrings(String[] digitStrings) Sets the array of strings used as digits, in order from 0 through 9voidsetExponentMultiplicationSign(String exponentMultiplicationSign) Sets the multiplication signvoidSets the string used to separate the mantissa from the exponent.voidsetGroupingSeparator(char groupingSeparator) Sets the character used for grouping separator.voidsetGroupingSeparatorString(String groupingSeparatorString) Sets the string used for grouping separator.voidsetInfinity(String infinity) Sets the String used to represent infinity.voidsetInternationalCurrencySymbol(String currency) Sets the international string denoting the local currency.voidsetMinusSign(char minusSign) Sets the character used to represent minus sign.voidsetMinusSignString(String minusSignString) Sets the string used to represent minus sign.voidsetMonetaryDecimalSeparator(char sep) Sets the monetary decimal separator.voidSets the monetary decimal separator string.voidsetMonetaryGroupingSeparator(char sep) Sets the monetary grouping separator.voidSets the monetary grouping separator string.voidSets the String used to represent NaN.voidsetPadEscape(char c) Sets the character used to pad numbers out to a specified width.voidsetPatternForCurrencySpacing(int itemType, boolean beforeCurrency, String pattern) Sets the indicated currency spacing pattern or value.voidsetPatternSeparator(char patternSeparator) Sets the character used to separate positive and negative subpatterns in a pattern.voidsetPercent(char percent) Sets the character used for percent sign.voidsetPercentString(String percentString) Sets the string used for percent sign.voidsetPerMill(char perMill) Sets the character used for mille percent sign.voidsetPerMillString(String perMillString) Sets the string used for permille sign.voidsetPlusSign(char plus) Sets the localized plus sign.voidsetPlusSignString(String plusSignString) Sets the localized plus sign string.voidsetSignificantDigit(char sigDigit) Sets the character used to represent a significant digit in a pattern.voidsetZeroDigit(char zeroDigit) Sets the character used for zero.
-
Field Details
-
CURRENCY_SPC_CURRENCY_MATCH
public static final int CURRENCY_SPC_CURRENCY_MATCHIndicates the currency match pattern used ingetPatternForCurrencySpacing(int, boolean).- See Also:
-
CURRENCY_SPC_SURROUNDING_MATCH
public static final int CURRENCY_SPC_SURROUNDING_MATCHIndicates the surrounding match pattern used ingetPatternForCurrencySpacing(int, boolean).- See Also:
-
CURRENCY_SPC_INSERT
public static final int CURRENCY_SPC_INSERTIndicates the insertion value used ingetPatternForCurrencySpacing(int, boolean).- See Also:
-
-
Constructor Details
-
DecimalFormatSymbols
public DecimalFormatSymbols()Creates a DecimalFormatSymbols object for the defaultFORMATlocale.- See Also:
-
DecimalFormatSymbols
Creates a DecimalFormatSymbols object for the given locale.- Parameters:
locale- the locale
-
DecimalFormatSymbols
Creates a DecimalFormatSymbols object for the given locale.- Parameters:
locale- the locale
-
-
Method Details
-
getInstance
Returns a DecimalFormatSymbols instance for the default locale.Note: Unlike
java.text.DecimalFormatSymbols#getInstance, this method simply returnsnew org.graalvm.shadowed.com.ibm.icu.text.DecimalFormatSymbols(). ICU currently does not supportDecimalFormatSymbolsProvider, which was introduced in Java 6.- Returns:
- A DecimalFormatSymbols instance.
-
getInstance
Returns a DecimalFormatSymbols instance for the given locale.Note: Unlike
java.text.DecimalFormatSymbols#getInstance, this method simply returnsnew org.graalvm.shadowed.com.ibm.icu.text.DecimalFormatSymbols(locale). ICU currently does not supportDecimalFormatSymbolsProvider, which was introduced in Java 6.- Parameters:
locale- the locale.- Returns:
- A DecimalFormatSymbols instance.
-
getInstance
Returns a DecimalFormatSymbols instance for the given locale.Note: Unlike
java.text.DecimalFormatSymbols#getInstance, this method simply returnsnew org.graalvm.shadowed.com.ibm.icu.text.DecimalFormatSymbols(locale). ICU currently does not supportDecimalFormatSymbolsProvider, which was introduced in Java 6.- Parameters:
locale- the locale.- Returns:
- A DecimalFormatSymbols instance.
-
forNumberingSystem
Returns a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the givenNumberingSystem.This method behaves equivalently to
getInstance()called with a locale having a "numbers=xxxx" keyword specifying the numbering system by name.In this method, the NumberingSystem argument will be used even if the locale has its own "numbers=xxxx" keyword.
- Parameters:
locale- the locale.ns- the numbering system.- Returns:
- A DecimalFormatSymbols instance.
-
forNumberingSystem
Returns a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the givenNumberingSystem.This method behaves equivalently to
getInstance()called with a locale having a "numbers=xxxx" keyword specifying the numbering system by name.In this method, the NumberingSystem argument will be used even if the locale has its own "numbers=xxxx" keyword.
- Parameters:
locale- the locale.ns- the numbering system.- Returns:
- A DecimalFormatSymbols instance.
-
getAvailableLocales
Returns an array of all locales for which thegetInstancemethods of this class can return localized instances.Note: Unlike
java.text.DecimalFormatSymbols#getAvailableLocales, this method simply returns the array ofLocales available for this class. ICU currently does not supportDecimalFormatSymbolsProvider, which was introduced in Java 6.- Returns:
- An array of
Locales for which localizedDecimalFormatSymbolsinstances are available.
-
getAvailableULocales
Returns an array of all locales for which thegetInstancemethods of this class can return localized instances.Note: Unlike
java.text.DecimalFormatSymbols#getAvailableLocales, this method simply returns the array ofULocales available in this class. ICU currently does not supportDecimalFormatSymbolsProvider, which was introduced in Java 6.- Returns:
- An array of
ULocales for which localizedDecimalFormatSymbolsinstances are available.
-
getZeroDigit
public char getZeroDigit()Returns the character used for zero. Different for Arabic, etc.- Returns:
- the character
-
getDigits
public char[] getDigits()Returns the array of characters used as digits, in order from 0 through 9- Returns:
- The array
- See Also:
-
setZeroDigit
public void setZeroDigit(char zeroDigit) Sets the character used for zero.Note: This method propagates digit 1 to digit 9 by incrementing code point one by one.
- Parameters:
zeroDigit- the zero character.
-
getDigitStrings
Returns the array of strings used as digits, in order from 0 through 9- Returns:
- The array of ten digit strings
- See Also:
-
getDigitStringsLocal
Deprecated.This API is ICU internal only.Returns the array of strings used as digits, in order from 0 through 9 Package private method - doesn't create a defensively copy.WARNING: Mutating the returned array will cause undefined behavior. If you need to change the value of the array, use
getDigitStrings()andsetDigitStrings(String[])instead.- Returns:
- the array of digit strings
-
getCodePointZero
Deprecated.This API is ICU internal only.If the digit strings array corresponds to a sequence of increasing code points, this method returns the code point corresponding to the first entry in the digit strings array. If the digit strings array is not a sequence of increasing code points, returns -1. -
setDigitStrings
Sets the array of strings used as digits, in order from 0 through 9Note:
When the input array of digit strings contains any strings represented by multiple Java chars, then
getDigits()will return the default digits ('0' - '9') andgetZeroDigit()will return the default zero digit ('0').- Parameters:
digitStrings- The array of digit strings. The length of the array must be exactly 10.- Throws:
NullPointerException- if thedigitStringsis null.IllegalArgumentException- if the length of the array is not 10.- See Also:
-
getSignificantDigit
public char getSignificantDigit()Returns the character used to represent a significant digit in a pattern.- Returns:
- the significant digit pattern character
-
setSignificantDigit
public void setSignificantDigit(char sigDigit) Sets the character used to represent a significant digit in a pattern.- Parameters:
sigDigit- the significant digit pattern character
-
getGroupingSeparator
public char getGroupingSeparator()Returns the character used for grouping separator. Different for French, etc.- Returns:
- the thousands character
-
setGroupingSeparator
public void setGroupingSeparator(char groupingSeparator) Sets the character used for grouping separator. Different for French, etc.- Parameters:
groupingSeparator- the thousands character- See Also:
-
getGroupingSeparatorString
Returns the string used for grouping separator. Different for French, etc.- Returns:
- the grouping separator string
- See Also:
-
setGroupingSeparatorString
Sets the string used for grouping separator.Note: When the input grouping separator String is represented by multiple Java chars, then
getGroupingSeparator()will return the default grouping separator character (',').- Parameters:
groupingSeparatorString- the grouping separator string- Throws:
NullPointerException- ifgroupingSeparatorStringis null.- See Also:
-
getDecimalSeparator
public char getDecimalSeparator()Returns the character used for decimal sign. Different for French, etc.- Returns:
- the decimal character
-
setDecimalSeparator
public void setDecimalSeparator(char decimalSeparator) Sets the character used for decimal sign. Different for French, etc.- Parameters:
decimalSeparator- the decimal character
-
getDecimalSeparatorString
Returns the string used for decimal sign.- Returns:
- the decimal sign string
- See Also:
-
setDecimalSeparatorString
Sets the string used for decimal sign.Note: When the input decimal separator String is represented by multiple Java chars, then
getDecimalSeparator()will return the default decimal separator character ('.').- Parameters:
decimalSeparatorString- the decimal sign string- Throws:
NullPointerException- ifdecimalSeparatorStringis null.- See Also:
-
getPerMill
public char getPerMill()Returns the character used for mille percent sign. Different for Arabic, etc.- Returns:
- the mille percent character
-
setPerMill
public void setPerMill(char perMill) Sets the character used for mille percent sign. Different for Arabic, etc.- Parameters:
perMill- the mille percent character
-
getPerMillString
Returns the string used for permille sign.- Returns:
- the permille string
- See Also:
-
setPerMillString
Sets the string used for permille sign.Note: When the input permille String is represented by multiple Java chars, then
getPerMill()will return the default permille character ('‰').- Parameters:
perMillString- the permille string- Throws:
NullPointerException- ifperMillStringis null.- See Also:
-
getPercent
public char getPercent()Returns the character used for percent sign. Different for Arabic, etc.- Returns:
- the percent character
-
setPercent
public void setPercent(char percent) Sets the character used for percent sign. Different for Arabic, etc.- Parameters:
percent- the percent character
-
getPercentString
Returns the string used for percent sign.- Returns:
- the percent string
- See Also:
-
setPercentString
Sets the string used for percent sign.Note: When the input grouping separator String is represented by multiple Java chars, then
getPercent()will return the default percent sign character ('%').- Parameters:
percentString- the percent string- Throws:
NullPointerException- ifpercentStringis null.- See Also:
-
getDigit
public char getDigit()Returns the character used for a digit in a pattern.- Returns:
- the digit pattern character
-
setDigit
public void setDigit(char digit) Sets the character used for a digit in a pattern.- Parameters:
digit- the digit pattern character
-
getPatternSeparator
public char getPatternSeparator()Returns the character used to separate positive and negative subpatterns in a pattern.- Returns:
- the pattern separator character
-
setPatternSeparator
public void setPatternSeparator(char patternSeparator) Sets the character used to separate positive and negative subpatterns in a pattern.- Parameters:
patternSeparator- the pattern separator character
-
getInfinity
Returns the String used to represent infinity. Almost always left unchanged.- Returns:
- the Infinity string
-
setInfinity
Sets the String used to represent infinity. Almost always left unchanged.- Parameters:
infinity- the Infinity String
-
getNaN
Returns the String used to represent NaN. Almost always left unchanged.- Returns:
- the NaN String
-
setNaN
Sets the String used to represent NaN. Almost always left unchanged.- Parameters:
NaN- the NaN String
-
getMinusSign
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
-
setMinusSign
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
-
getMinusSignString
Returns the string used to represent minus sign.- Returns:
- the minus sign string
- See Also:
-
setMinusSignString
Sets the string used to represent minus sign.Note: When the input minus sign String is represented by multiple Java chars, then
getMinusSign()will return the default minus sign character ('-').- Parameters:
minusSignString- the minus sign string- Throws:
NullPointerException- ifminusSignStringis null.- See Also:
-
getPlusSign
public char getPlusSign()Returns the localized plus sign.- Returns:
- the plus sign, used in localized patterns and formatted strings
- See Also:
-
setPlusSign
public void setPlusSign(char plus) Sets the localized plus sign.- Parameters:
plus- the plus sign, used in localized patterns and formatted strings- See Also:
-
getPlusSignString
Returns the string used to represent plus sign.- Returns:
- the plus sign string
-
setPlusSignString
Sets the localized plus sign string.Note: When the input plus sign String is represented by multiple Java chars, then
getPlusSign()will return the default plus sign character ('+').- Parameters:
plusSignString- the plus sign string, used in localized patterns and formatted strings- Throws:
NullPointerException- ifplusSignStringis null.- See Also:
-
getApproximatelySignString
Deprecated.This API is for technology preview only. -
setApproximatelySignString
Deprecated.This API is for technology preview only. -
getCurrencySymbol
Returns the string denoting the local currency.- Returns:
- the local currency String.
-
setCurrencySymbol
Sets the string denoting the local currency.- Parameters:
currency- the local currency String.
-
getInternationalCurrencySymbol
Returns the international string denoting the local currency.- Returns:
- the international string denoting the local currency
-
setInternationalCurrencySymbol
Sets the international string denoting the local currency.- Parameters:
currency- the international string denoting the local currency.
-
getCurrency
Returns the currency symbol, forgetCurrency()API compatibility only. ICU clients should use the Currency API directly.- Returns:
- the currency used, or null
-
setCurrency
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- ifcurrencyis null- See Also:
-
getMonetaryDecimalSeparator
public char getMonetaryDecimalSeparator()Returns the monetary decimal separator.- Returns:
- the monetary decimal separator character
-
setMonetaryDecimalSeparator
public void setMonetaryDecimalSeparator(char sep) Sets the monetary decimal separator.- Parameters:
sep- the monetary decimal separator character
-
getMonetaryDecimalSeparatorString
Returns the monetary decimal separator string.- Returns:
- the monetary decimal separator string
- See Also:
-
setMonetaryDecimalSeparatorString
Sets the monetary decimal separator string.Note: When the input monetary decimal separator String is represented by multiple Java chars, then
getMonetaryDecimalSeparatorString()will return the default monetary decimal separator character ('.').- Parameters:
sep- the monetary decimal separator string- Throws:
NullPointerException- ifsepis null.- See Also:
-
getMonetaryGroupingSeparator
public char getMonetaryGroupingSeparator()Returns the monetary grouping separator.- Returns:
- the monetary grouping separator character
-
setMonetaryGroupingSeparator
public void setMonetaryGroupingSeparator(char sep) Sets the monetary grouping separator.- Parameters:
sep- the monetary grouping separator character
-
getMonetaryGroupingSeparatorString
Returns the monetary grouping separator.- Returns:
- the monetary grouping separator string
- See Also:
-
setMonetaryGroupingSeparatorString
Sets the monetary grouping separator string.Note: When the input grouping separator String is represented by multiple Java chars, then
getMonetaryGroupingSeparator()will return the default monetary grouping separator character (',').- Parameters:
sep- the monetary grouping separator string- Throws:
NullPointerException- ifsepis null.- See Also:
-
getCurrencyPattern
Deprecated.This API is for ICU internal use onlyInternal API for NumberFormat- Returns:
- String currency pattern string
-
getExponentMultiplicationSign
Returns the multiplication sign -
setExponentMultiplicationSign
Sets the multiplication sign -
getExponentSeparator
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
- See Also:
-
setExponentSeparator
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- See Also:
-
getPadEscape
public char getPadEscape()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
- See Also:
-
setPadEscape
public void setPadEscape(char c) 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.- See Also:
-
getPatternForCurrencySpacing
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.
- Parameters:
itemType- one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH or CURRENCY_SPC_INSERTbeforeCurrency- true to get thebeforeCurrencyvalues, false to get theafterCurrencyvalues.- Returns:
- the value, or null.
- See Also:
-
setPatternForCurrencySpacing
Sets the indicated currency spacing pattern or value. SeegetPatternForCurrencySpacing(int, boolean)for more information.Values for currency match and surrounding match must be
UnicodeSetpatterns. 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_INSERTbeforeCurrency- 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.- See Also:
-
getLocale
Returns the locale for which this object was constructed.- Returns:
- the locale for which this object was constructed
-
getULocale
Returns the locale for which this object was constructed.- Returns:
- the locale for which this object was constructed
-
clone
-
equals
-
hashCode
-
getLocale
Returns the locale that was used to create this object, or null. This may may differ from the locale requested at the time of this object's creation. For example, if an object is created for locale en_US_CALIFORNIA, the actual data may be drawn from en (the actual locale), and en_US may be the most specific locale that exists (the valid locale).Note: The actual locale is returned correctly, but the valid locale is not, in most cases.
- Parameters:
type- type of information requested, eitherULocale.VALID_LOCALEorULocale.ACTUAL_LOCALE.- Returns:
- the information specified by type, or null if this object was not constructed from locale data.
- See Also:
-