Package java.text

Class DecimalFormatSymbols

java.lang.Object
java.text.DecimalFormatSymbols
All Implemented Interfaces:
Serializable, Cloneable

public class DecimalFormatSymbols
extends Object
implements Cloneable, Serializable
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:
Locale, DecimalFormat, Serialized Form
  • Constructor Details

    • DecimalFormatSymbols

      public 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 DecimalFormat.getDecimalFormatSymbols().
    • DecimalFormatSymbols

      public 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 DecimalFormat.getDecimalFormatSymbols().
      Parameters:
      locale - the locale.
  • Method Details

    • getInstance

      public static DecimalFormatSymbols getInstance()
      Returns a new DecimalFormatSymbols instance for the user's default locale. See "Be wary of the default locale".
      Returns:
      an instance of DecimalFormatSymbols
      Since:
      1.6
    • getInstance

      public static DecimalFormatSymbols getInstance​(Locale locale)
      Returns a new DecimalFormatSymbols for the given locale.
      Parameters:
      locale - the locale
      Returns:
      an instance of DecimalFormatSymbols
      Throws:
      NullPointerException - if locale == null
      Since:
      1.6
    • getAvailableLocales

      public static 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.

      Since:
      1.6
    • clone

      public Object clone()
      Description copied from class: Object
      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.
      Overrides:
      clone in class Object
      Returns:
      a copy of this object.
    • equals

      public 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.
      Overrides:
      equals in class Object
      Parameters:
      object - the object to compare with this object.
      Returns:
      true if the specified object is equal to this DecimalFormatSymbols; false otherwise.
      See Also:
      hashCode()
    • toString

      public String toString()
      Description copied from class: Object
      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.

      Overrides:
      toString in class Object
      Returns:
      a printable representation of this object.
    • getCurrency

      public 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:
      the currency that was set in the constructor or by calling setCurrency() or setInternationalCurrencySymbol(), or null if an invalid currency was set.
      See Also:
      setCurrency(Currency), setInternationalCurrencySymbol(String)
    • getInternationalCurrencySymbol

      public String getInternationalCurrencySymbol()
      Returns the international currency symbol.
      Returns:
      the international currency symbol as string.
    • getCurrencySymbol

      public 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

      public String 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

      public String 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

      public String getExponentSeparator()
    • hashCode

      public int hashCode()
      Description copied from class: Object
      Returns an integer hash code for this object. By contract, any two objects for which Object.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.

      Overrides:
      hashCode in class Object
      Returns:
      this object's hash code.
      See Also:
      Object.equals(java.lang.Object)
    • setCurrency

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

      public 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 - the currency code.
    • setCurrencySymbol

      public void setCurrencySymbol​(String value)
      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

      public void setInfinity​(String value)
      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

      public void setNaN​(String value)
      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

      public void setExponentSeparator​(String value)
      Sets the string used to separate mantissa and exponent. Typically "E", as in "1.2E3".
      Since:
      1.6