Skip to content

Most visited

Recently visited

navigation
Added in API level 1

DecimalFormatSymbols

public class DecimalFormatSymbols
extends Object implements Cloneable, Serializable

java.lang.Object
   ↳ java.text.DecimalFormatSymbols


Encapsulates the set of symbols (such as the decimal separator, the grouping separator, and so on) needed by 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:

Summary

Public constructors

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.

Public methods

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(Locale locale)

Returns a new DecimalFormatSymbols for the given locale.

static DecimalFormatSymbols getInstance()

Returns a new DecimalFormatSymbols instance for the user's default locale.

String getInternationalCurrencySymbol()

Returns the international currency symbol.

char getMinusSign()

Returns the minus sign character.

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 getPerMill()

Returns the per mill sign character.

char getPercent()

Returns the percent 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 setPerMill(char value)

Sets the per mill sign character.

void setPercent(char value)

Sets the percent 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.

Inherited methods

From class java.lang.Object

Public constructors

DecimalFormatSymbols

Added in API level 1
DecimalFormatSymbols ()

Constructs a new 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 getDecimalFormatSymbols().

DecimalFormatSymbols

Added in API level 1
DecimalFormatSymbols (Locale locale)

Constructs a new DecimalFormatSymbols containing the symbols for the specified 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 getDecimalFormatSymbols().

Parameters
locale Locale: the locale.

Public methods

clone

Added in API level 1
Object clone ()

Creates and returns a copy of this Object. 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.

Returns
Object a copy of this object.

equals

Added in API level 1
boolean equals (Object object)

Compares the specified object to this DecimalFormatSymbols and indicates if they are equal. In order to be equal, object must be an instance of DecimalFormatSymbols and contain the same symbols.

Parameters
object Object: the object to compare with this object.
Returns
boolean true if the specified object is equal to this DecimalFormatSymbols; false otherwise.

See also:

getAvailableLocales

Added in API level 9
Locale[] getAvailableLocales ()

Returns an array of locales for which custom DecimalFormatSymbols instances are available.

Note that Android does not support user-supplied locale service providers.

Returns
Locale[]

getCurrency

Added in API level 1
Currency getCurrency ()

Returns the currency.

null is returned if setInternationalCurrencySymbol() has been previously called with a value that is not a valid ISO 4217 currency code.

Returns
Currency the currency that was set in the constructor or by calling setCurrency() or setInternationalCurrencySymbol(), or null if an invalid currency was set.

See also:

getCurrencySymbol

Added in API level 1
String getCurrencySymbol ()

Returns the currency symbol.

Returns
String the currency symbol as string.

getDecimalSeparator

Added in API level 1
char getDecimalSeparator ()

Returns the character which represents the decimal point in a number.

Returns
char the decimal separator character.

getDigit

Added in API level 1
char getDigit ()

Returns the character which represents a single digit in a format pattern.

Returns
char the digit pattern character.

getExponentSeparator

Added in API level 9
String getExponentSeparator ()

Returns
String

getGroupingSeparator

Added in API level 1
char getGroupingSeparator ()

Returns the character used as the thousands separator in a number.

Returns
char the thousands separator character.

getInfinity

Added in API level 1
String getInfinity ()

Returns the string which represents infinity.

Returns
String the infinity symbol as a string.

getInstance

Added in API level 9
DecimalFormatSymbols getInstance (Locale locale)

Returns a new DecimalFormatSymbols for the given locale.

Parameters
locale Locale: the locale
Returns
DecimalFormatSymbols an instance of DecimalFormatSymbols
Throws
NullPointerException if locale == null

getInstance

Added in API level 9
DecimalFormatSymbols getInstance ()

Returns a new DecimalFormatSymbols instance for the user's default locale. See "Be wary of the default locale".

Returns
DecimalFormatSymbols an instance of DecimalFormatSymbols

getInternationalCurrencySymbol

Added in API level 1
String getInternationalCurrencySymbol ()

Returns the international currency symbol.

Returns
String the international currency symbol as string.

getMinusSign

Added in API level 1
char getMinusSign ()

Returns the minus sign character.

Returns
char the minus sign as a character.

getMonetaryDecimalSeparator

Added in API level 1
char getMonetaryDecimalSeparator ()

Returns the character which represents the decimal point in a monetary value.

Returns
char the monetary decimal point as a character.

getNaN

Added in API level 1
String getNaN ()

Returns the string which represents NaN.

Returns
String the symbol NaN as a string.

getPatternSeparator

Added in API level 1
char getPatternSeparator ()

Returns the character which separates the positive and negative patterns in a format pattern.

Returns
char the pattern separator character.

getPerMill

Added in API level 1
char getPerMill ()

Returns the per mill sign character.

Returns
char the per mill sign character.

getPercent

Added in API level 1
char getPercent ()

Returns the percent character.

Returns
char the percent character.

getZeroDigit

Added in API level 1
char getZeroDigit ()

Returns the character which represents zero.

Returns
char the zero character.

hashCode

Added in API level 1
int hashCode ()

Returns an integer hash code for this object. By contract, any two objects for which equals(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.

Returns
int this object's hash code.

setCurrency

Added in API level 1
void setCurrency (Currency currency)

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 Currency: the new currency.
Throws
NullPointerException if currency is null.

setCurrencySymbol

Added in API level 1
void setCurrencySymbol (String value)

Sets the currency symbol.

Parameters
value String: the currency symbol.

setDecimalSeparator

Added in API level 1
void setDecimalSeparator (char value)

Sets the character which represents the decimal point in a number.

Parameters
value char: the decimal separator character.

setDigit

Added in API level 1
void setDigit (char value)

Sets the character which represents a single digit in a format pattern.

Parameters
value char: the digit character.

setExponentSeparator

Added in API level 9
void setExponentSeparator (String value)

Sets the string used to separate mantissa and exponent. Typically "E", as in "1.2E3".

Parameters
value String

setGroupingSeparator

Added in API level 1
void setGroupingSeparator (char value)

Sets the character used as the thousands separator in a number.

Parameters
value char: the grouping separator character.

setInfinity

Added in API level 1
void setInfinity (String value)

Sets the string which represents infinity.

Parameters
value String: the string representing infinity.

setInternationalCurrencySymbol

Added in API level 1
void setInternationalCurrencySymbol (String value)

Sets the international currency symbol.

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.

Parameters
value String: the currency code.

setMinusSign

Added in API level 1
void setMinusSign (char value)

Sets the minus sign character.

Parameters
value char: the minus sign character.

setMonetaryDecimalSeparator

Added in API level 1
void setMonetaryDecimalSeparator (char value)

Sets the character which represents the decimal point in a monetary value.

Parameters
value char: the monetary decimal separator character.

setNaN

Added in API level 1
void setNaN (String value)

Sets the string which represents NaN.

Parameters
value String: the string representing NaN.

setPatternSeparator

Added in API level 1
void setPatternSeparator (char value)

Sets the character which separates the positive and negative patterns in a format pattern.

Parameters
value char: the pattern separator character.

setPerMill

Added in API level 1
void setPerMill (char value)

Sets the per mill sign character.

Parameters
value char: the per mill character.

setPercent

Added in API level 1
void setPercent (char value)

Sets the percent character.

Parameters
value char: the percent character.

setZeroDigit

Added in API level 1
void setZeroDigit (char value)

Sets the character which represents zero.

Parameters
value char: the zero digit character.

toString

Added in API level 1
String toString ()

Returns 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 toString method if you intend implementing your own toString method.

Returns
String a printable representation of this object.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.