com.ibm.icu.text
Class DecimalFormatSymbols

java.lang.Object
  extended by com.ibm.icu.text.DecimalFormatSymbols
All Implemented Interfaces:
Serializable, Cloneable

public class DecimalFormatSymbols
extends Object
implements Cloneable, Serializable

This class represents the set of symbols (such as the decimal separator, the grouping separator, and so on) needed by DecimalFormat to format numbers. DecimalFormat creates for itself 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.

This is an enhanced version of DecimalFormatSymbols that is based on the standard version in the JDK. New or changed functionality is labeled NEW.

Author:
Mark Davis, Alan Liu
See Also:
Locale, DecimalFormat, Serialized Form
Status:
Stable ICU 2.0.

Constructor Summary
DecimalFormatSymbols()
          Create a DecimalFormatSymbols object for the default locale.
DecimalFormatSymbols(Locale locale)
          Create a DecimalFormatSymbols object for the given locale.
DecimalFormatSymbols(ULocale locale)
          Create a DecimalFormatSymbols object for the given locale.
 
Method Summary
 Object clone()
          Standard override.
 boolean equals(Object obj)
          Override equals.
static Locale[] getAvailableLocales()
          Returns an array of all locales for which the getInstance methods of this class can return localized instances.
static ULocale[] getAvailableULocales()
          Returns an array of all locales for which the getInstance methods of this class can return localized instances.
 Currency getCurrency()
          Returns the currency symbol, for JDK 1.4 compatibility only.
 String getCurrencySymbol()
          Return the string denoting the local currency.
 char getDecimalSeparator()
          Return the character used for decimal sign.
 char getDigit()
          Return the character used for a digit in a pattern.
 String getExponentSeparator()
          NEW Return the string used to separate the mantissa from the exponent.
 char getGroupingSeparator()
          Return the character used for thousands separator.
 String getInfinity()
          Return the String used to represent infinity.
static DecimalFormatSymbols getInstance()
          Gets a DecimalFormatSymbols instance for the default locale.
static DecimalFormatSymbols getInstance(Locale locale)
          Gets a DecimalFormatSymbols instance for the given locale.
static DecimalFormatSymbols getInstance(ULocale locale)
          Gets a DecimalFormatSymbols instance for the given locale.
 String getInternationalCurrencySymbol()
          Return the international string denoting the local currency.
 Locale getLocale()
          Returns the locale for which this object was constructed.
 ULocale getLocale(ULocale.Type type)
          Return the locale that was used to create this object, or null.
 char getMinusSign()
          Return the character used to represent minus sign.
 char getMonetaryDecimalSeparator()
          Return the monetary decimal separator.
 char getMonetaryGroupingSeparator()
          Return the monetary decimal separator.
 String getNaN()
          Return the String used to represent NaN.
 char getPadEscape()
          NEW Return the character used to pad numbers out to a specified width.
 char getPatternSeparator()
          Return the character used to separate positive and negative subpatterns in a pattern.
 char getPercent()
          Return the character used for percent sign.
 char getPerMill()
          Return the character used for mille percent sign.
 char getPlusSign()
          NEW Return the localized plus sign.
 char getSignificantDigit()
          Return the character used to represent a significant digit in a pattern.
 ULocale getULocale()
          Returns the locale for which this object was constructed.
 char getZeroDigit()
          Return the character used for zero.
 int hashCode()
          Override hashCode
 void setCurrency(Currency currency)
          ICU does not use the DecimalFormatSymbols for the currency any more.
 void setCurrencySymbol(String currency)
          Set the string denoting the local currency.
 void setDecimalSeparator(char decimalSeparator)
          Set the character used for decimal sign.
 void setDigit(char digit)
          Set the character used for a digit in a pattern.
 void setExponentSeparator(String exp)
          NEW Set the string used to separate the mantissa from the exponent.
 void setGroupingSeparator(char groupingSeparator)
          Set the character used for thousands separator.
 void setInfinity(String infinity)
          Set the String used to represent infinity.
 void setInternationalCurrencySymbol(String currency)
          Set the international string denoting the local currency.
 void setMinusSign(char minusSign)
          Set the character used to represent minus sign.
 void setMonetaryDecimalSeparator(char sep)
          Set the monetary decimal separator.
 void setMonetaryGroupingSeparator(char sep)
          Set the monetary decimal separator.
 void setNaN(String NaN)
          Set the String used to represent NaN.
 void setPadEscape(char c)
          NEW Set the character used to pad numbers out to a specified width.
 void setPatternSeparator(char patternSeparator)
          Set the character used to separate positive and negative subpatterns in a pattern.
 void setPercent(char percent)
          Set the character used for percent sign.
 void setPerMill(char perMill)
          Set the character used for mille percent sign.
 void setPlusSign(char plus)
          NEW Set the localized plus sign.
 void setSignificantDigit(char sigDigit)
          Set the character used to represent a significant digit in a pattern.
 void setZeroDigit(char zeroDigit)
          Set the character used for zero.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecimalFormatSymbols

public DecimalFormatSymbols()
Create a DecimalFormatSymbols object for the default locale.

Status:
Stable ICU 2.0.

DecimalFormatSymbols

public DecimalFormatSymbols(Locale locale)
Create a DecimalFormatSymbols object for the given locale.

Parameters:
locale - the locale
Status:
Stable ICU 2.0.

DecimalFormatSymbols

public DecimalFormatSymbols(ULocale locale)
Create a DecimalFormatSymbols object for the given locale.

Parameters:
locale - the locale
Status:
Stable ICU 3.2.
Method Detail

getInstance

public static DecimalFormatSymbols getInstance()
Gets a DecimalFormatSymbols instance for the default locale.

Note: Unlike java.text.DecimalFormatSymbols#getInstance, this method simply returns new com.ibm.icu.text.DecimalFormatSymbols(). ICU does not support DecimalFormatSymbolsProvider introduced in Java 6 or its equivalent implementation for now.

Returns:
A DecimalFormatSymbols instance.
Status:
Stable ICU 3.8.

getInstance

public static DecimalFormatSymbols getInstance(Locale locale)
Gets a DecimalFormatSymbols instance for the given locale.

Note: Unlike java.text.DecimalFormatSymbols#getInstance, this method simply returns new com.ibm.icu.text.DecimalFormatSymbols(locale). ICU does not support DecimalFormatSymbolsProvider introduced in Java 6 or its equivalent implementation for now.

Parameters:
locale - the locale.
Returns:
A DecimalFormatSymbols instance.
Status:
Stable ICU 3.8.

getInstance

public static DecimalFormatSymbols getInstance(ULocale locale)
Gets a DecimalFormatSymbols instance for the given locale.

Note: Unlike java.text.DecimalFormatSymbols#getInstance, this method simply returns new com.ibm.icu.text.DecimalFormatSymbols(locale). ICU does not support DecimalFormatSymbolsProvider introduced in Java 6 or its equivalent implementation for now.

Parameters:
locale - the locale.
Returns:
A DecimalFormatSymbols instance.
Status:
Draft ICU 3.8.

getAvailableLocales

public static Locale[] getAvailableLocales()
Returns an array of all locales for which the getInstance methods of this class can return localized instances.

Note: Unlike java.text.DecimalFormatSymbols#getAvailableLocales, this method simply returns the array of Locales available for this class. ICU does not support DecimalFormatSymbolsProvider introduced in Java 6 or its equivalent implementation for now.

Returns:
An array of Locales for which localized DecimalFormatSymbols instances are available.
Status:
Stable ICU 3.8.

getAvailableULocales

public static ULocale[] getAvailableULocales()
Returns an array of all locales for which the getInstance methods of this class can return localized instances.

Note: Unlike java.text.DecimalFormatSymbols#getAvailableLocales, this method simply returns the array of ULocales available in this class. ICU does not support DecimalFormatSymbolsProvider introduced in Java 6 or its equivalent implementation for now.

Returns:
An array of ULocales for which localized DecimalFormatSymbols instances are available.
Status:
Draft ICU 3.8.

getZeroDigit

public char getZeroDigit()
Return the character used for zero. Different for Arabic, etc.

Returns:
the character
Status:
Stable ICU 2.0.

setZeroDigit

public void setZeroDigit(char zeroDigit)
Set the character used for zero.

Parameters:
zeroDigit - the zero character.
Status:
Stable ICU 2.0.

getSignificantDigit

public char getSignificantDigit()
Return the character used to represent a significant digit in a pattern.

Returns:
the significant digit pattern character
Status:
Stable ICU 3.0.

setSignificantDigit

public void setSignificantDigit(char sigDigit)
Set the character used to represent a significant digit in a pattern.

Parameters:
sigDigit - the significant digit pattern character
Status:
Stable ICU 3.0.

getGroupingSeparator

public char getGroupingSeparator()
Return the character used for thousands separator. Different for French, etc.

Returns:
the thousands character
Status:
Stable ICU 2.0.

setGroupingSeparator

public void setGroupingSeparator(char groupingSeparator)
Set the character used for thousands separator. Different for French, etc.

Parameters:
groupingSeparator - the thousands character
Status:
Stable ICU 2.0.

getDecimalSeparator

public char getDecimalSeparator()
Return the character used for decimal sign. Different for French, etc.

Returns:
the decimal character
Status:
Stable ICU 2.0.

setDecimalSeparator

public void setDecimalSeparator(char decimalSeparator)
Set the character used for decimal sign. Different for French, etc.

Parameters:
decimalSeparator - the decimal character
Status:
Stable ICU 2.0.

getPerMill

public char getPerMill()
Return the character used for mille percent sign. Different for Arabic, etc.

Returns:
the mille percent character
Status:
Stable ICU 2.0.

setPerMill

public void setPerMill(char perMill)
Set the character used for mille percent sign. Different for Arabic, etc.

Parameters:
perMill - the mille percent character
Status:
Stable ICU 2.0.

getPercent

public char getPercent()
Return the character used for percent sign. Different for Arabic, etc.

Returns:
the percent character
Status:
Stable ICU 2.0.

setPercent

public void setPercent(char percent)
Set the character used for percent sign. Different for Arabic, etc.

Parameters:
percent - the percent character
Status:
Stable ICU 2.0.

getDigit

public char getDigit()
Return the character used for a digit in a pattern.

Returns:
the digit pattern character
Status:
Stable ICU 2.0.

setDigit

public void setDigit(char digit)
Set the character used for a digit in a pattern.

Parameters:
digit - the digit pattern character
Status:
Stable ICU 2.0.

getPatternSeparator

public char getPatternSeparator()
Return the character used to separate positive and negative subpatterns in a pattern.

Returns:
the pattern separator character
Status:
Stable ICU 2.0.

setPatternSeparator

public void setPatternSeparator(char patternSeparator)
Set the character used to separate positive and negative subpatterns in a pattern.

Parameters:
patternSeparator - the pattern separator character
Status:
Stable ICU 2.0.

getInfinity

public String getInfinity()
Return the String used to represent infinity. Almost always left unchanged.

Returns:
the Infinity string
Status:
Stable ICU 2.0.

setInfinity

public void setInfinity(String infinity)
Set the String used to represent infinity. Almost always left unchanged.

Parameters:
infinity - the Infinity String
Status:
Stable ICU 2.0.

getNaN

public String getNaN()
Return the String used to represent NaN. Almost always left unchanged.

Returns:
the NaN String
Status:
Stable ICU 2.0.

setNaN

public void setNaN(String NaN)
Set the String used to represent NaN. Almost always left unchanged.

Parameters:
NaN - the NaN String
Status:
Stable ICU 2.0.

getMinusSign

public char getMinusSign()
Return the character used to represent minus sign. If no explicit negative format is specified, one is formed by prefixing minusSign to the positive format.

Returns:
the minus sign character
Status:
Stable ICU 2.0.

setMinusSign

public void setMinusSign(char minusSign)
Set the character used to represent minus sign. If no explicit negative format is specified, one is formed by prefixing minusSign to the positive format.

Parameters:
minusSign - the minus sign character
Status:
Stable ICU 2.0.

getCurrencySymbol

public String getCurrencySymbol()
Return the string denoting the local currency.

Returns:
the local currency String.
Status:
Stable ICU 2.0.

setCurrencySymbol

public void setCurrencySymbol(String currency)
Set the string denoting the local currency.

Parameters:
currency - the local currency String.
Status:
Stable ICU 2.0.

getInternationalCurrencySymbol

public String getInternationalCurrencySymbol()
Return the international string denoting the local currency.

Returns:
the international string denoting the local currency
Status:
Stable ICU 2.0.

setInternationalCurrencySymbol

public void setInternationalCurrencySymbol(String currency)
Set the international string denoting the local currency.

Parameters:
currency - the international string denoting the local currency.
Status:
Stable ICU 2.0.

getCurrency

public Currency getCurrency()
Returns the currency symbol, for JDK 1.4 compatibility only. ICU clients should use the Currency API directly.

Returns:
the currency used, or null
Status:
Stable ICU 3.4.

setCurrency

public void setCurrency(Currency currency)
ICU does not use the DecimalFormatSymbols for the currency any more. This API is present for API compatibility only. This also sets the currency symbol attribute to the currency's symbol in the DecimalFormatSymbols' locale, and the international currency symbol attribute to the currency's ISO 4217 currency code.

Parameters:
currency - the new currency to be used
Throws:
NullPointerException - if currency is null
See Also:
setCurrencySymbol(java.lang.String), setInternationalCurrencySymbol(java.lang.String)
Status:
Stable ICU 3.4.

getMonetaryDecimalSeparator

public char getMonetaryDecimalSeparator()
Return the monetary decimal separator.

Returns:
the monetary decimal separator character
Status:
Stable ICU 2.0.

getMonetaryGroupingSeparator

public char getMonetaryGroupingSeparator()
Return the monetary decimal separator.

Returns:
the monetary decimal separator character
Status:
Stable ICU 3.6.

setMonetaryDecimalSeparator

public void setMonetaryDecimalSeparator(char sep)
Set the monetary decimal separator.

Parameters:
sep - the monetary decimal separator character
Status:
Stable ICU 2.0.

setMonetaryGroupingSeparator

public void setMonetaryGroupingSeparator(char sep)
Set the monetary decimal separator.

Parameters:
sep - the monetary decimal separator character
Status:
Stable ICU 3.6.

getExponentSeparator

public String getExponentSeparator()
NEW Return the string used to separate the mantissa from the exponent. Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.

Returns:
the localized exponent symbol, used in localized patterns and formatted strings
See Also:
setExponentSeparator(java.lang.String)
Status:
Stable ICU 2.0.

setExponentSeparator

public void setExponentSeparator(String exp)
NEW Set the string used to separate the mantissa from the exponent. Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.

Parameters:
exp - the localized exponent symbol, used in localized patterns and formatted strings
See Also:
getExponentSeparator()
Status:
Stable ICU 2.0.

getPlusSign

public char getPlusSign()
NEW Return the localized plus sign.

Returns:
the plus sign, used in localized patterns and formatted strings
See Also:
setPlusSign(char), setMinusSign(char), getMinusSign()
Status:
Stable ICU 2.0.

setPlusSign

public void setPlusSign(char plus)
NEW Set the localized plus sign.

Parameters:
plus - the plus sign, used in localized patterns and formatted strings
See Also:
getPlusSign(), setMinusSign(char), getMinusSign()
Status:
Stable ICU 2.0.

getPadEscape

public char getPadEscape()
NEW Return the character used to pad numbers out to a specified width. This is not the pad character itself; rather, it is the special pattern character preceding the pad character. In the pattern "*_#,##0", '*' is the pad escape, and '_' is the pad character.

Returns:
the character
See Also:
setPadEscape(char), DecimalFormat.getFormatWidth(), DecimalFormat.getPadPosition(), DecimalFormat.getPadCharacter()
Status:
Stable ICU 2.0.

setPadEscape

public void setPadEscape(char c)
NEW Set the character used to pad numbers out to a specified width. This is not the pad character itself; rather, it is the special pattern character preceding the pad character. In the pattern "*_#,##0", '*' is the pad escape, and '_' is the pad character.

See Also:
getPadEscape(), DecimalFormat.setFormatWidth(int), DecimalFormat.setPadPosition(int), DecimalFormat.setPadCharacter(char)
Status:
Stable ICU 2.0.

getLocale

public Locale getLocale()
Returns the locale for which this object was constructed.

Returns:
the locale for which this object was constructed
Status:
Stable ICU 2.0.

getULocale

public ULocale getULocale()
Returns the locale for which this object was constructed.

Returns:
the locale for which this object was constructed
Status:
Stable ICU 3.2.

clone

public Object clone()
Standard override.

Overrides:
clone in class Object
Status:
Stable ICU 2.0.

equals

public boolean equals(Object obj)
Override equals.

Overrides:
equals in class Object
Status:
Stable ICU 2.0.

hashCode

public int hashCode()
Override hashCode

Overrides:
hashCode in class Object
Status:
Stable ICU 2.0.

getLocale

public final ULocale getLocale(ULocale.Type type)
Return the locale that was used to create this object, or null. This may may differ from the locale requested at the time of this object's creation. For example, if an object is created for locale en_US_CALIFORNIA, the actual data may be drawn from en (the actual locale), and en_US may be the most specific locale that exists (the valid locale).

Note: This method will be implemented in ICU 3.0; ICU 2.8 contains a partial preview implementation. The * actual locale is returned correctly, but the valid locale is not, in most cases.

Parameters:
type - type of information requested, either ULocale.VALID_LOCALE or ULocale.ACTUAL_LOCALE.
Returns:
the information specified by type, or null if this object was not constructed from locale data.
See Also:
ULocale, ULocale.VALID_LOCALE, ULocale.ACTUAL_LOCALE
Status:
Draft ICU 2.8 (retain).


Copyright (c) 2009 IBM Corporation and others.