Class DecimalFormatSymbols
- All Implemented Interfaces:
Serializable,Cloneable
public class DecimalFormatSymbols extends Object implements Cloneable, Serializable
DecimalFormat to format numbers.
DecimalFormat internally creates 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:
Locale,DecimalFormat, Serialized Form
-
Constructor Summary
Constructors Constructor Description DecimalFormatSymbols()Constructs a newDecimalFormatSymbolscontaining the symbols for the user's default locale.DecimalFormatSymbols(Locale locale)Constructs a new DecimalFormatSymbols containing the symbols for the specified Locale. -
Method Summary
Modifier and Type Method Description Objectclone()Creates and returns a copy of thisObject.booleanequals(Object object)Compares the specified object to thisDecimalFormatSymbolsand indicates if they are equal.static Locale[]getAvailableLocales()Returns an array of locales for which customDecimalFormatSymbolsinstances are available.CurrencygetCurrency()Returns the currency.StringgetCurrencySymbol()Returns the currency symbol.chargetDecimalSeparator()Returns the character which represents the decimal point in a number.chargetDigit()Returns the character which represents a single digit in a format pattern.StringgetExponentSeparator()chargetGroupingSeparator()Returns the character used as the thousands separator in a number.StringgetInfinity()Returns the string which represents infinity.static DecimalFormatSymbolsgetInstance()Returns a newDecimalFormatSymbolsinstance for the user's default locale.static DecimalFormatSymbolsgetInstance(Locale locale)Returns a newDecimalFormatSymbolsfor the given locale.StringgetInternationalCurrencySymbol()Returns the international currency symbol.chargetMinusSign()Returns the minus sign character.chargetMonetaryDecimalSeparator()Returns the character which represents the decimal point in a monetary value.StringgetNaN()Returns the string which represents NaN.chargetPatternSeparator()Returns the character which separates the positive and negative patterns in a format pattern.chargetPercent()Returns the percent character.chargetPerMill()Returns the per mill sign character.chargetZeroDigit()Returns the character which represents zero.inthashCode()Returns an integer hash code for this object.voidsetCurrency(Currency currency)Sets the currency.voidsetCurrencySymbol(String value)Sets the currency symbol.voidsetDecimalSeparator(char value)Sets the character which represents the decimal point in a number.voidsetDigit(char value)Sets the character which represents a single digit in a format pattern.voidsetExponentSeparator(String value)Sets the string used to separate mantissa and exponent.voidsetGroupingSeparator(char value)Sets the character used as the thousands separator in a number.voidsetInfinity(String value)Sets the string which represents infinity.voidsetInternationalCurrencySymbol(String value)Sets the international currency symbol.voidsetMinusSign(char value)Sets the minus sign character.voidsetMonetaryDecimalSeparator(char value)Sets the character which represents the decimal point in a monetary value.voidsetNaN(String value)Sets the string which represents NaN.voidsetPatternSeparator(char value)Sets the character which separates the positive and negative patterns in a format pattern.voidsetPercent(char value)Sets the percent character.voidsetPerMill(char value)Sets the per mill sign character.voidsetZeroDigit(char value)Sets the character which represents zero.StringtoString()Returns a string containing a concise, human-readable description of this object.
-
Constructor Details
-
DecimalFormatSymbols
public DecimalFormatSymbols()Constructs a newDecimalFormatSymbolscontaining the symbols for the user's default locale. See "Be wary of the default locale". Best practice is to create aDecimalFormatand then to get theDecimalFormatSymbolsfrom that object by callingDecimalFormat.getDecimalFormatSymbols(). -
DecimalFormatSymbols
Constructs a new DecimalFormatSymbols containing the symbols for the specified Locale. See "Be wary of the default locale". Best practice is to create aDecimalFormatand then to get theDecimalFormatSymbolsfrom that object by callingDecimalFormat.getDecimalFormatSymbols().- Parameters:
locale- the locale.
-
-
Method Details
-
getInstance
Returns a newDecimalFormatSymbolsinstance for the user's default locale. See "Be wary of the default locale".- Returns:
- an instance of
DecimalFormatSymbols - Since:
- 1.6
-
getInstance
Returns a newDecimalFormatSymbolsfor the given locale.- Parameters:
locale- the locale- Returns:
- an instance of
DecimalFormatSymbols - Throws:
NullPointerException- iflocale == null- Since:
- 1.6
-
getAvailableLocales
Returns an array of locales for which customDecimalFormatSymbolsinstances are available.Note that Android does not support user-supplied locale service providers.
- Since:
- 1.6
-
clone
Description copied from class:ObjectCreates 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
Compares the specified object to thisDecimalFormatSymbolsand indicates if they are equal. In order to be equal,objectmust be an instance ofDecimalFormatSymbolsand contain the same symbols.- Overrides:
equalsin classObject- Parameters:
object- the object to compare with this object.- Returns:
trueif the specified object is equal to thisDecimalFormatSymbols;falseotherwise.- See Also:
hashCode()
-
toString
Description copied from class:ObjectReturns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toStringmethod if you intend implementing your owntoStringmethod. -
getCurrency
Returns the currency.nullis returned ifsetInternationalCurrencySymbol()has been previously called with a value that is not a valid ISO 4217 currency code.- Returns:
- the currency that was set in the constructor or by calling
setCurrency()orsetInternationalCurrencySymbol(), ornullif an invalid currency was set. - See Also:
setCurrency(Currency),setInternationalCurrencySymbol(String)
-
getInternationalCurrencySymbol
Returns the international currency symbol.- Returns:
- the international currency symbol as string.
-
getCurrencySymbol
Returns the currency symbol.- Returns:
- the currency symbol as string.
-
getDecimalSeparator
public char getDecimalSeparator()Returns the character which represents the decimal point in a number.- Returns:
- the decimal separator character.
-
getDigit
public char getDigit()Returns the character which represents a single digit in a format pattern.- Returns:
- the digit pattern character.
-
getGroupingSeparator
public char getGroupingSeparator()Returns the character used as the thousands separator in a number.- Returns:
- the thousands separator character.
-
getInfinity
Returns the string which represents infinity.- Returns:
- the infinity symbol as a string.
-
getMinusSign
public char getMinusSign()Returns the minus sign character.- Returns:
- the minus sign as a character.
-
getMonetaryDecimalSeparator
public char getMonetaryDecimalSeparator()Returns the character which represents the decimal point in a monetary value.- Returns:
- the monetary decimal point as a character.
-
getNaN
Returns the string which represents NaN.- Returns:
- the symbol NaN as a string.
-
getPatternSeparator
public char getPatternSeparator()Returns the character which separates the positive and negative patterns in a format pattern.- Returns:
- the pattern separator character.
-
getPercent
public char getPercent()Returns the percent character.- Returns:
- the percent character.
-
getPerMill
public char getPerMill()Returns the per mill sign character.- Returns:
- the per mill sign character.
-
getZeroDigit
public char getZeroDigit()Returns the character which represents zero.- Returns:
- the zero character.
-
getExponentSeparator
-
hashCode
public int hashCode()Description copied from class:ObjectReturns 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)
-
setCurrency
Sets the currency.The international currency symbol and the currency symbol are updated, but the min and max number of fraction digits stays the same.
- Parameters:
currency- the new currency.- Throws:
NullPointerException- ifcurrencyisnull.
-
setInternationalCurrencySymbol
Sets the international currency symbol.The currency and currency symbol are also updated if
valueis a valid ISO4217 currency code.The min and max number of fraction digits stay the same.
- Parameters:
value- the currency code.
-
setCurrencySymbol
Sets the currency symbol.- Parameters:
value- the currency symbol.
-
setDecimalSeparator
public void setDecimalSeparator(char value)Sets the character which represents the decimal point in a number.- Parameters:
value- the decimal separator character.
-
setDigit
public void setDigit(char value)Sets the character which represents a single digit in a format pattern.- Parameters:
value- the digit character.
-
setGroupingSeparator
public void setGroupingSeparator(char value)Sets the character used as the thousands separator in a number.- Parameters:
value- the grouping separator character.
-
setInfinity
Sets the string which represents infinity.- Parameters:
value- the string representing infinity.
-
setMinusSign
public void setMinusSign(char value)Sets the minus sign character.- Parameters:
value- the minus sign character.
-
setMonetaryDecimalSeparator
public void setMonetaryDecimalSeparator(char value)Sets the character which represents the decimal point in a monetary value.- Parameters:
value- the monetary decimal separator character.
-
setNaN
Sets the string which represents NaN.- Parameters:
value- the string representing NaN.
-
setPatternSeparator
public void setPatternSeparator(char value)Sets the character which separates the positive and negative patterns in a format pattern.- Parameters:
value- the pattern separator character.
-
setPercent
public void setPercent(char value)Sets the percent character.- Parameters:
value- the percent character.
-
setPerMill
public void setPerMill(char value)Sets the per mill sign character.- Parameters:
value- the per mill character.
-
setZeroDigit
public void setZeroDigit(char value)Sets the character which represents zero.- Parameters:
value- the zero digit character.
-
setExponentSeparator
Sets the string used to separate mantissa and exponent. Typically "E", as in "1.2E3".- Since:
- 1.6
-