Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.text.DecimalFormatSymbols
DecimalFormat
to format numbers and currency
for a particular locale. These are
normally handled automatically, but an application can override
values as desired using this class.
DecimalFormat
, Serialized FormConstructor Summary | |
| |
|
Method Summary | |
Object |
|
boolean | |
Currency |
|
String |
|
char |
|
char |
|
char |
|
String |
|
static DecimalFormatSymbols |
|
static DecimalFormatSymbols |
|
String |
|
char |
|
char |
|
String |
|
char |
|
char |
|
char |
|
char |
|
int |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public DecimalFormatSymbols()
This method initializes a new instance ofDecimalFormatSymbols
for the default locale. This constructor only obtains instances using the runtime's resources; to also includeDateFormatSymbolsProvider
instances, callgetInstance()
instead.
- See Also:
getInstance()
public DecimalFormatSymbols(Locale loc)
This method initializes a new instance ofDecimalFormatSymbols
for the specified locale. Note: if the locale does not have an associatedCurrency
instance, the currency symbol and international currency symbol will be set to the strings "?" and "XXX" respectively. This generally happens with language locales (those with no specified country), such asLocale.ENGLISH
. This constructor only obtains instances using the runtime's resources; to also includeDecimalFormatSymbolsProvider
instances, callgetInstance(Locale)
instead.
- Parameters:
loc
- The local to load symbols for.
- Throws:
NullPointerException
- if the locale is null.
- See Also:
getInstance(Locale)
public Object clone()
This method may be called to create a new copy of the Object. The typical behavior is as follows:
o == o.clone()
is falseo.getClass() == o.clone().getClass()
is trueo.equals(o)
is trueHowever, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override
Object.equals(Object)
.If the Object you call clone() on does not implement
Cloneable
(which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.
All array types implement Cloneable, and override this method as follows (it should never fail):
public Object clone() { try { super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } }
- Returns:
- a copy of the Object
- See Also:
Cloneable
public boolean equals(Object obj)
This method this this object for equality against the specified object. This will be true if and only if the following criteria are met with regard to the specified object:
- It is not
null
.- It is an instance of
DecimalFormatSymbols
.- All of its symbols are identical to the symbols in this object.
- Returns:
true
if the specified object is equal to this object,false
otherwise.
public Currency getCurrency()
Returns the currency corresponding to the currency symbol stored in this instance ofDecimalFormatSymbols
.
- Returns:
- An instance of
Currency
which matches the currency used, or null if there is no corresponding instance.
public String getCurrencySymbol()
This method returns the currency symbol in local format. For example, "$" for Canadian dollars.
- Returns:
- The currency symbol in local format.
public char getDecimalSeparator()
This method returns the character used as the decimal point.
- Returns:
- The character used as the decimal point.
public char getDigit()
This method returns the character used to represent a digit in a format pattern string.
- Returns:
- The character used to represent a digit in a format pattern string.
public char getGroupingSeparator()
This method sets the character used to separate groups of digits. For example, the United States uses a comma (,) to separate thousands in a number.
- Returns:
- The character used to separate groups of digits.
public String getInfinity()
This method returns the character used to represent infinity.
- Returns:
- The character used to represent infinity.
public static final DecimalFormatSymbols getInstance()
Returns aDecimalFormatSymbols
instance for the default locale obtained from either the runtime itself or one of the installedDecimalFormatSymbolsProvider
instances. This is equivalent to callinggetInstance(Locale.getDefault())
.
- Returns:
- a
DecimalFormatSymbols
instance for the default locale.
- Since:
- 1.6
public static final DecimalFormatSymbols getInstance(Locale locale)
Returns aDecimalFormatSymbols
instance for the specified locale obtained from either the runtime itself or one of the installedDecimalFormatSymbolsProvider
instances.
- Parameters:
locale
- the locale for which an instance should be returned.
- Returns:
- a
DecimalFormatSymbols
instance for the specified locale.
- Throws:
NullPointerException
- iflocale
isnull
.
- Since:
- 1.6
public String getInternationalCurrencySymbol()
This method returns the ISO 4217 currency code for the currency used.
- Returns:
- the ISO 4217 currency code.
public char getMinusSign()
This method returns the character used to represent the minus sign.
- Returns:
- The character used to represent the minus sign.
public char getMonetaryDecimalSeparator()
This method returns the character used to represent the decimal point for currency values.
- Returns:
- The decimal point character used in currency values.
public String getNaN()
This method returns the string used to represent the NaN (not a number) value.
- Returns:
- The string used to represent NaN
public char getPatternSeparator()
This method returns the character used to separate positive and negative subpatterns in a format pattern.
- Returns:
- The character used to separate positive and negative subpatterns in a format pattern.
public char getPerMill()
This method returns the character used as the per mille character.
- Returns:
- The per mille character.
public char getPercent()
This method returns the character used as the percent sign.
- Returns:
- The character used as the percent sign.
public char getZeroDigit()
This method returns the character used to represent the digit zero.
- Returns:
- The character used to represent the digit zero.
public int hashCode()
This method returns a hash value for this object.
- Returns:
- A hash value for this object.
public void setCurrency(Currency currency)
This method sets the currency symbol and ISO 4217 currency code to the values obtained from the supplied currency.
- Parameters:
currency
- the currency from which to obtain the values.
- Throws:
NullPointerException
- if the currency is null.
public void setCurrencySymbol(String currency)
This method sets the currency symbol to the specified value.
- Parameters:
currency
- The new currency symbol
public void setDecimalSeparator(char decimalSep)
This method sets the decimal point character to the specified value.
- Parameters:
decimalSep
- The new decimal point character
public void setDigit(char digit)
This method sets the character used to represents a digit in a format string to the specified value.
- Parameters:
digit
- The character used to represent a digit in a format pattern.
public void setGroupingSeparator(char groupSep)
This method sets the character used to separate groups of digits.
- Parameters:
groupSep
- The character used to separate groups of digits.
public void setInfinity(String infinity)
This method sets the string used to represents infinity.
- Parameters:
infinity
- The string used to represent infinity.
public void setInternationalCurrencySymbol(String currencyCode)
This method sets the international currency symbol to the specified value. If a validCurrency
instance exists for the international currency code, then this is used for the currency attribute, and the currency symbol is set to the corresponding value from this instance. Otherwise, the currency attribute is set to null and the symbol is left unmodified.
- Parameters:
currencyCode
- The new international currency symbol.
public void setMinusSign(char minusSign)
This method sets the character used to represent the minus sign.
- Parameters:
minusSign
- The character used to represent the minus sign.
public void setMonetaryDecimalSeparator(char decimalSep)
This method sets the character used for the decimal point in currency values.
- Parameters:
decimalSep
- The decimal point character used in currency values.
public void setNaN(String nan)
This method sets the string used to represent the NaN (not a number) value.
- Parameters:
nan
- The string used to represent NaN
public void setPatternSeparator(char patternSep)
This method sets the character used to separate positive and negative subpatterns in a format pattern.
- Parameters:
patternSep
- The character used to separate positive and negative subpatterns in a format pattern.
public void setPerMill(char perMill)
This method sets the character used as the per mille character.
- Parameters:
perMill
- The per mille character.
public void setPercent(char percent)
This method sets the character used as the percent sign.
- Parameters:
percent
- The character used as the percent sign.
public void setZeroDigit(char zeroDigit)
This method sets the character used to represent the digit zero.
- Parameters:
zeroDigit
- The character used to represent the digit zero.