Class DecimalFormatSymbols
- java.lang.Object
-
- com.ibm.icu.text.DecimalFormatSymbols
-
- All Implemented Interfaces:
Serializable,Cloneable
public class DecimalFormatSymbols extends Object implements Cloneable, Serializable
. This class represents the set of symbols (such as the decimal separator, the grouping separator, and so on) needed byDecimalFormatto format numbers.DecimalFormatcreates for itself an instance ofDecimalFormatSymbolsfrom its locale data. If you need to change any of these symbols, you can get theDecimalFormatSymbolsobject from yourDecimalFormatand modify it.- See Also:
Locale,DecimalFormat, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intCURRENCY_SPC_CURRENCY_MATCHIndicates the currency match pattern used ingetPatternForCurrencySpacing(int, boolean).static intCURRENCY_SPC_INSERTIndicates the insertion value used ingetPatternForCurrencySpacing(int, boolean).static intCURRENCY_SPC_SURROUNDING_MATCHIndicates the surrounding match pattern used ingetPatternForCurrencySpacing(int, boolean).
-
Constructor Summary
Constructors Constructor Description DecimalFormatSymbols()Creates a DecimalFormatSymbols object for the defaultFORMATlocale.DecimalFormatSymbols(ULocale locale)Creates a DecimalFormatSymbols object for the given locale.DecimalFormatSymbols(Locale locale)Creates a DecimalFormatSymbols object for the given locale.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Objectclone()Creates and returns a copy of thisObject.booleanequals(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 thegetInstancemethods of this class can return localized instances.static ULocale[]getAvailableULocales()Returns an array of all locales for which thegetInstancemethods of this class can return localized instances.CurrencygetCurrency()Returns the currency symbol, for JDK 1.4 compatibility only.StringgetCurrencySymbol()Returns the string denoting the local currency.chargetDecimalSeparator()Returns the character used for decimal sign.chargetDigit()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 9StringgetExponentMultiplicationSign()Returns the multiplication signStringgetExponentSeparator()Returns the string used to separate the mantissa from the exponent.chargetGroupingSeparator()Returns the character used for thousands separator.StringgetInfinity()Returns the String used to represent infinity.static DecimalFormatSymbolsgetInstance()Returns a DecimalFormatSymbols instance for the default locale.static DecimalFormatSymbolsgetInstance(ULocale locale)Returns a DecimalFormatSymbols instance for the given locale.static DecimalFormatSymbolsgetInstance(Locale locale)Returns a DecimalFormatSymbols instance for the given locale.StringgetInternationalCurrencySymbol()Returns the international string denoting the local currency.LocalegetLocale()Returns the locale for which this object was constructed.ULocalegetLocale(ULocale.Type type)Returns the locale that was used to create this object, or null.chargetMinusSign()Returns the character used to represent minus sign.StringgetMinusString()Deprecated.This API is ICU internal only.chargetMonetaryDecimalSeparator()Returns the monetary decimal separator.chargetMonetaryGroupingSeparator()Returns the monetary grouping separator.StringgetNaN()Returns the String used to represent NaN.chargetPadEscape()Returns the character used to pad numbers out to a specified width.StringgetPatternForCurrencySpacing(int itemType, boolean beforeCurrency)Returns the desired currency spacing value.chargetPatternSeparator()Returns the character used to separate positive and negative subpatterns in a pattern.chargetPercent()Returns the character used for percent sign.chargetPerMill()Returns the character used for mille percent sign.chargetPlusSign()Returns the localized plus sign.StringgetPlusString()Deprecated.This API is ICU internal only.chargetSignificantDigit()Returns the character used to represent a significant digit in a pattern.ULocalegetULocale()Returns the locale for which this object was constructed.chargetZeroDigit()Returns the character used for zero.inthashCode()Returns an integer hash code for this object.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.voidsetDigit(char digit)Sets the character used for a digit in a pattern.voidsetExponentMultiplicationSign(String exponentMultiplicationSign)Sets the multiplication signvoidsetExponentSeparator(String exp)Sets the string used to separate the mantissa from the exponent.voidsetGroupingSeparator(char groupingSeparator)Sets the character used for thousands 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.voidsetMonetaryDecimalSeparator(char sep)Sets the monetary decimal separator.voidsetMonetaryGroupingSeparator(char sep)Sets the monetary decimal separator.voidsetNaN(String NaN)Sets 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.voidsetPerMill(char perMill)Sets the character used for mille percent sign.voidsetPlusSign(char plus)Sets the localized plus sign.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 Detail
-
CURRENCY_SPC_CURRENCY_MATCH
public static final int CURRENCY_SPC_CURRENCY_MATCH
Indicates the currency match pattern used ingetPatternForCurrencySpacing(int, boolean).- See Also:
- Constant Field Values
-
CURRENCY_SPC_SURROUNDING_MATCH
public static final int CURRENCY_SPC_SURROUNDING_MATCH
Indicates the surrounding match pattern used ingetPatternForCurrencySpacing(int, boolean).- See Also:
- Constant Field Values
-
CURRENCY_SPC_INSERT
public static final int CURRENCY_SPC_INSERT
Indicates the insertion value used ingetPatternForCurrencySpacing(int, boolean).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DecimalFormatSymbols
public DecimalFormatSymbols()
Creates a DecimalFormatSymbols object for the defaultFORMATlocale.- See Also:
ULocale.Category.FORMAT
-
DecimalFormatSymbols
public DecimalFormatSymbols(Locale locale)
Creates a DecimalFormatSymbols object for the given locale.- Parameters:
locale- the locale
-
DecimalFormatSymbols
public DecimalFormatSymbols(ULocale locale)
Creates a DecimalFormatSymbols object for the given locale.- Parameters:
locale- the locale
-
-
Method Detail
-
getInstance
public static DecimalFormatSymbols getInstance()
Returns a DecimalFormatSymbols instance for the default locale.Note: Unlike
java.text.DecimalFormatSymbols#getInstance, this method simply returnsnew com.ibm.icu.text.DecimalFormatSymbols(). ICU currently does not supportDecimalFormatSymbolsProvider, which was introduced in Java 6.- Returns:
- A DecimalFormatSymbols instance.
-
getInstance
public static DecimalFormatSymbols getInstance(Locale locale)
Returns a DecimalFormatSymbols instance for the given locale.Note: Unlike
java.text.DecimalFormatSymbols#getInstance, this method simply returnsnew 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
public static DecimalFormatSymbols getInstance(ULocale locale)
Returns a DecimalFormatSymbols instance for the given locale.Note: Unlike
java.text.DecimalFormatSymbols#getInstance, this method simply returnsnew 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.
-
getAvailableLocales
public static Locale[] 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
public static ULocale[] 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
-
setZeroDigit
public void setZeroDigit(char zeroDigit)
Sets the character used for zero.- Parameters:
zeroDigit- the zero character.
-
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 thousands separator. Different for French, etc.- Returns:
- the thousands character
-
setGroupingSeparator
public void setGroupingSeparator(char groupingSeparator)
Sets the character used for thousands separator. Different for French, etc.- Parameters:
groupingSeparator- the thousands character
-
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
-
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
-
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
-
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
public String getInfinity()
Returns the String used to represent infinity. Almost always left unchanged.- Returns:
- the Infinity string
-
setInfinity
public void setInfinity(String infinity)
Sets the String used to represent infinity. Almost always left unchanged.- Parameters:
infinity- the Infinity String
-
getNaN
public String getNaN()
Returns the String used to represent NaN. Almost always left unchanged.- Returns:
- the NaN String
-
setNaN
public void setNaN(String NaN)
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
-
getMinusString
@Deprecated public String getMinusString()
Deprecated.This API is ICU internal only.Returns the string used to represent minus sign.- Returns:
- the minus sign string
-
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
-
getCurrencySymbol
public String getCurrencySymbol()
Returns the string denoting the local currency.- Returns:
- the local currency String.
-
setCurrencySymbol
public void setCurrencySymbol(String currency)
Sets the string denoting the local currency.- Parameters:
currency- the local currency String.
-
getInternationalCurrencySymbol
public String getInternationalCurrencySymbol()
Returns the international string denoting the local currency.- Returns:
- the international string denoting the local currency
-
setInternationalCurrencySymbol
public void setInternationalCurrencySymbol(String currency)
Sets the international string denoting the local currency.- Parameters:
currency- the international string denoting the local currency.
-
getCurrency
public Currency getCurrency()
Returns the currency symbol, for JDK 1.4 compatibility only. ICU clients should use the Currency API directly.- Returns:
- the currency used, or null
-
setCurrency
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- ifcurrencyis null- See Also:
setCurrencySymbol(java.lang.String),setInternationalCurrencySymbol(java.lang.String)
-
getMonetaryDecimalSeparator
public char getMonetaryDecimalSeparator()
Returns the monetary decimal separator.- Returns:
- the monetary decimal separator character
-
getMonetaryGroupingSeparator
public char getMonetaryGroupingSeparator()
Returns the monetary grouping separator.- Returns:
- the monetary grouping separator character
-
setMonetaryDecimalSeparator
public void setMonetaryDecimalSeparator(char sep)
Sets the monetary decimal separator.- Parameters:
sep- the monetary decimal separator character
-
setMonetaryGroupingSeparator
public void setMonetaryGroupingSeparator(char sep)
Sets the monetary decimal separator.- Parameters:
sep- the monetary decimal separator character
-
getExponentMultiplicationSign
public String getExponentMultiplicationSign()
Returns the multiplication sign
-
setExponentMultiplicationSign
public void setExponentMultiplicationSign(String exponentMultiplicationSign)
Sets the multiplication sign
-
getExponentSeparator
public String 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(java.lang.String)
-
setExponentSeparator
public void setExponentSeparator(String exp)
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:
getExponentSeparator()
-
getPlusSign
public char getPlusSign()
Returns the localized plus sign.- Returns:
- the plus sign, used in localized patterns and formatted strings
- See Also:
setPlusSign(char),setMinusSign(char),getMinusSign()
-
getPlusString
@Deprecated public String getPlusString()
Deprecated.This API is ICU internal only.Returns the string used to represent plus sign.- Returns:
- the plus sign string
-
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:
getPlusSign(),setMinusSign(char),getMinusSign()
-
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(char),DecimalFormat.getFormatWidth(),DecimalFormat.getPadPosition(),DecimalFormat.getPadCharacter()
-
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.
-
getPatternForCurrencySpacing
public String getPatternForCurrencySpacing(int itemType, boolean beforeCurrency)
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_INSERTbeforeCurrency- true to get thebeforeCurrencyvalues, false to get theafterCurrencyvalues.- Returns:
- the value, or null.
- See Also:
setPatternForCurrencySpacing(int, boolean, String)
-
setPatternForCurrencySpacing
public void setPatternForCurrencySpacing(int itemType, boolean beforeCurrency, String pattern)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:
getPatternForCurrencySpacing(int, boolean)
-
getLocale
public Locale getLocale()
Returns the locale for which this object was constructed.- Returns:
- the locale for which this object was constructed
-
getULocale
public ULocale getULocale()
Returns the locale for which this object was constructed.- Returns:
- the locale for which this object was constructed
-
clone
public Object clone()
Creates and returns a copy of thisObject. 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 callsuper.clone()to create the new instance and then create deep copies of the nested, mutable objects.
-
equals
public boolean equals(Object obj)
Compares this instance with the specified object and indicates if they are equal. In order to be equal,omust 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
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
obj- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Returns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually 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
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
getLocale
public final ULocale getLocale(ULocale.Type type)
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:
ULocale,ULocale.VALID_LOCALE,ULocale.ACTUAL_LOCALE
-
-