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.Locale,
DecimalFormat,
Serialized Form| Constructor and Description |
|---|
DecimalFormatSymbols()
Constructs a new
DecimalFormatSymbols containing the symbols for
the user's default locale. |
DecimalFormatSymbols(Locale locale)
Constructs a new DecimalFormatSymbols containing the symbols for the
specified Locale.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Creates and returns a copy of this
Object. |
boolean |
equals(Object object)
Compares the specified object to this
DecimalFormatSymbols and
indicates if they are equal. |
static Locale[] |
getAvailableLocales()
Returns an array of locales for which custom
DecimalFormatSymbols instances
are available. |
Currency |
getCurrency()
Returns the currency.
|
String |
getCurrencySymbol()
Returns the currency symbol.
|
char |
getDecimalSeparator()
Returns the character which represents the decimal point in a number.
|
char |
getDigit()
Returns the character which represents a single digit in a format
pattern.
|
String |
getExponentSeparator() |
char |
getGroupingSeparator()
Returns the character used as the thousands separator in a number.
|
String |
getInfinity()
Returns the string which represents infinity.
|
static DecimalFormatSymbols |
getInstance()
Returns a new
DecimalFormatSymbols instance for the user's default locale. |
static DecimalFormatSymbols |
getInstance(Locale locale)
Returns a new
DecimalFormatSymbols for the given locale. |
String |
getInternationalCurrencySymbol()
Returns the international currency symbol.
|
char |
getMinusSign()
Returns the minus sign character.
|
String |
getMinusSignString() |
char |
getMonetaryDecimalSeparator()
Returns the character which represents the decimal point in a monetary
value.
|
String |
getNaN()
Returns the string which represents NaN.
|
char |
getPatternSeparator()
Returns the character which separates the positive and negative patterns
in a format pattern.
|
char |
getPercent()
Returns the percent character.
|
String |
getPercentString() |
char |
getPerMill()
Returns the per mill sign character.
|
char |
getZeroDigit()
Returns the character which represents zero.
|
int |
hashCode()
Returns an integer hash code for this object.
|
void |
setCurrency(Currency currency)
Sets the currency.
|
void |
setCurrencySymbol(String value)
Sets the currency symbol.
|
void |
setDecimalSeparator(char value)
Sets the character which represents the decimal point in a number.
|
void |
setDigit(char value)
Sets the character which represents a single digit in a format pattern.
|
void |
setExponentSeparator(String value)
Sets the string used to separate mantissa and exponent.
|
void |
setGroupingSeparator(char value)
Sets the character used as the thousands separator in a number.
|
void |
setInfinity(String value)
Sets the string which represents infinity.
|
void |
setInternationalCurrencySymbol(String value)
Sets the international currency symbol.
|
void |
setMinusSign(char value)
Sets the minus sign character.
|
void |
setMonetaryDecimalSeparator(char value)
Sets the character which represents the decimal point in a monetary
value.
|
void |
setNaN(String value)
Sets the string which represents NaN.
|
void |
setPatternSeparator(char value)
Sets the character which separates the positive and negative patterns in
a format pattern.
|
void |
setPercent(char value)
Sets the percent character.
|
void |
setPerMill(char value)
Sets the per mill sign character.
|
void |
setZeroDigit(char value)
Sets the character which represents zero.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
public DecimalFormatSymbols()
DecimalFormatSymbols containing the symbols for
the user's default locale.
See "Be wary of the default locale".
Best practice is to create a DecimalFormat
and then to get the DecimalFormatSymbols from that object by
calling DecimalFormat.getDecimalFormatSymbols().public DecimalFormatSymbols(Locale locale)
DecimalFormat
and then to get the DecimalFormatSymbols from that object by
calling DecimalFormat.getDecimalFormatSymbols().locale - the locale.public static DecimalFormatSymbols getInstance()
DecimalFormatSymbols instance for the user's default locale.
See "Be wary of the default locale".DecimalFormatSymbolspublic static DecimalFormatSymbols getInstance(Locale locale)
DecimalFormatSymbols for the given locale.locale - the localeDecimalFormatSymbolsNullPointerException - if locale == nullpublic static Locale[] getAvailableLocales()
DecimalFormatSymbols instances
are available.
Note that Android does not support user-supplied locale service providers.
public Object clone()
ObjectObject. 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.public boolean equals(Object object)
DecimalFormatSymbols and
indicates if they are equal. In order to be equal, object must be
an instance of DecimalFormatSymbols and contain the same symbols.equals in class Objectobject - the object to compare with this object.true if the specified object is equal to this
DecimalFormatSymbols; false otherwise.hashCode()public String toString()
ObjectgetClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString method
if you intend implementing your own toString method.
public Currency getCurrency()
null is returned if setInternationalCurrencySymbol() has
been previously called with a value that is not a valid ISO 4217 currency
code.
setCurrency() or setInternationalCurrencySymbol(),
or null if an invalid currency was set.setCurrency(Currency),
setInternationalCurrencySymbol(String)public String getInternationalCurrencySymbol()
public String getCurrencySymbol()
public char getDecimalSeparator()
public char getDigit()
public char getGroupingSeparator()
public String getInfinity()
public char getMinusSign()
public String getMinusSignString()
public String getPercentString()
public char getMonetaryDecimalSeparator()
public String getNaN()
public char getPatternSeparator()
public char getPercent()
public char getPerMill()
public char getZeroDigit()
public String getExponentSeparator()
public int hashCode()
ObjectObject.equals(java.lang.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.
hashCode in class ObjectObject.equals(java.lang.Object)public void setCurrency(Currency currency)
The international currency symbol and the currency symbol are updated, but the min and max number of fraction digits stays the same.
currency - the new currency.NullPointerException - if currency is null.public void setInternationalCurrencySymbol(String value)
The currency and currency symbol are also updated if value is a
valid ISO4217 currency code.
The min and max number of fraction digits stay the same.
value - the currency code.public void setCurrencySymbol(String value)
value - the currency symbol.public void setDecimalSeparator(char value)
value - the decimal separator character.public void setDigit(char value)
value - the digit character.public void setGroupingSeparator(char value)
value - the grouping separator character.public void setInfinity(String value)
value - the string representing infinity.public void setMinusSign(char value)
value - the minus sign character.public void setMonetaryDecimalSeparator(char value)
value - the monetary decimal separator character.public void setNaN(String value)
value - the string representing NaN.public void setPatternSeparator(char value)
value - the pattern separator character.public void setPercent(char value)
value - the percent character.public void setPerMill(char value)
value - the per mill character.public void setZeroDigit(char value)
value - the zero digit character.public void setExponentSeparator(String value)