Class DecimalFormatSymbols
- java.lang.Object
-
- com.ibm.icu.text.DecimalFormatSymbols
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class DecimalFormatSymbols extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
. This class represents the set of symbols (such as the decimal separator, the grouping separator, and so on) needed byDecimalFormat
to format numbers.DecimalFormat
creates for itself an instance ofDecimalFormatSymbols
from its locale data. If you need to change any of these symbols, you can get theDecimalFormatSymbols
object from yourDecimalFormat
and modify it.- See Also:
Locale
,DecimalFormat
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DecimalFormatSymbols.CacheData
private static class
DecimalFormatSymbols.DecFmtDataSink
Sink for enumerating all of the decimal format symbols (more specifically, anything under the "NumberElements.symbols" tree).
-
Field Summary
Fields Modifier and Type Field Description private ULocale
actualLocale
The locale containing data used to construct this object, or null.private java.lang.String
approximatelyString
The string used to indicate an approximately sign.private static CacheBase<ULocale,DecimalFormatSymbols.CacheData,java.lang.Void>
cachedLocaleData
cache to hold the NumberElements of a Locale.private int
codePointZero
Dealing with code points is faster than dealing with strings when formatting.private Currency
currency
static int
CURRENCY_SPC_CURRENCY_MATCH
Indicates the currency match pattern used ingetPatternForCurrencySpacing(int, boolean)
.static int
CURRENCY_SPC_INSERT
Indicates the insertion value used ingetPatternForCurrencySpacing(int, boolean)
.static int
CURRENCY_SPC_SURROUNDING_MATCH
Indicates the surrounding match pattern used ingetPatternForCurrencySpacing(int, boolean)
.private java.lang.String
currencyPattern
private java.lang.String[]
currencySpcAfterSym
private java.lang.String[]
currencySpcBeforeSym
private java.lang.String
currencySymbol
String denoting the local currency, e.g.private static int
currentSerialVersion
private char
decimalSeparator
Character used for decimal sign.private java.lang.String
decimalSeparatorString
String used for decimal sign.private static char
DEF_DECIMAL_SEPARATOR
private static char[]
DEF_DIGIT_CHARS_ARRAY
private static java.lang.String[]
DEF_DIGIT_STRINGS_ARRAY
private static char
DEF_GROUPING_SEPARATOR
private static char
DEF_MINUS_SIGN
private static char
DEF_PERCENT
private static char
DEF_PERMILL
private static char
DEF_PLUS_SIGN
private char
digit
Character used for a digit in a pattern.private char[]
digits
Array of characters used for the digits 0-9 in order.private java.lang.String[]
digitStrings
Array of Strings used for the digits 0-9 in order.private char
exponential
The character used to distinguish the exponent in a number formatted in exponential notation, e.g.private java.lang.String
exponentMultiplicationSign
Exponent multiplication sign.private java.lang.String
exponentSeparator
The string used to separate the mantissa from the exponent.private char
groupingSeparator
Character used for thousands separator.private java.lang.String
groupingSeparatorString
String used for thousands separator.private java.lang.String
infinity
Character used to represent infinity.private java.lang.String
intlCurrencySymbol
International string denoting the local currency, e.g.private static java.lang.String
LATIN_NUMBERING_SYSTEM
Constants for path names in the data bundles.private char
minusSign
Character used to represent minus sign.private java.lang.String
minusString
String versions of minus sign.private char
monetaryGroupingSeparator
The grouping separator character used when formatting currency values.private java.lang.String
monetaryGroupingSeparatorString
The grouping separator string used when formatting currency values.private char
monetarySeparator
The decimal separator character used when formatting currency values.private java.lang.String
monetarySeparatorString
The decimal separator string used when formatting currency values.private java.lang.String
NaN
Character used to represent NaN.private static java.lang.String
NUMBER_ELEMENTS
private char
padEscape
The character used to indicate a padding character in a format, e.g., '*' in a pattern such as "$*_#,##0.00".private char
patternSeparator
Character used to separate positive and negative subpatterns in a pattern.private char
percent
Character used for percent sign.private java.lang.String
percentString
String used for percent sign.private char
perMill
Character used for mille percent sign.private java.lang.String
perMillString
String used for mille percent sign.private char
plusSign
The character used to indicate a plus sign.private java.lang.String
plusString
String versions of plus sign.private java.util.Locale
requestedLocale
The locale for which this object was constructed.private int
serialVersionOnStream
Describes the version ofDecimalFormatSymbols
present on the stream.private static long
serialVersionUID
private char
sigDigit
Character used for a significant digit in a pattern.private static java.lang.String[]
SYMBOL_DEFAULTS
List of default values for the symbols.private static java.lang.String[]
SYMBOL_KEYS
List of field names to be loaded from the data files.private static java.lang.String
SYMBOLS
private ULocale
ulocale
The requested ULocale.private ULocale
validLocale
The most specific locale containing any resource data, or null.private char
zeroDigit
Character used for zero.
-
Constructor Summary
Constructors Modifier Constructor Description DecimalFormatSymbols()
Creates a DecimalFormatSymbols object for the defaultFORMAT
locale.DecimalFormatSymbols(ULocale locale)
Creates a DecimalFormatSymbols object for the given locale.private
DecimalFormatSymbols(ULocale locale, NumberingSystem ns)
DecimalFormatSymbols(java.util.Locale locale)
Creates a DecimalFormatSymbols object for the given locale.private
DecimalFormatSymbols(java.util.Locale locale, NumberingSystem ns)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Object
clone()
boolean
equals(java.lang.Object obj)
static DecimalFormatSymbols
forNumberingSystem(ULocale locale, NumberingSystem ns)
Returns a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the givenNumberingSystem
.static DecimalFormatSymbols
forNumberingSystem(java.util.Locale locale, NumberingSystem ns)
Returns a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the givenNumberingSystem
.java.lang.String
getApproximatelySignString()
Deprecated.This API is for technology preview only.static java.util.Locale[]
getAvailableLocales()
Returns an array of all locales for which thegetInstance
methods of this class can return localized instances.static ULocale[]
getAvailableULocales()
Returns an array of all locales for which thegetInstance
methods of this class can return localized instances.int
getCodePointZero()
Deprecated.This API is ICU internal only.Currency
getCurrency()
Returns the currency symbol, forgetCurrency()
API compatibility only.java.lang.String
getCurrencyPattern()
Deprecated.This API is for ICU internal use onlyjava.lang.String
getCurrencySymbol()
Returns the string denoting the local currency.char
getDecimalSeparator()
Returns the character used for decimal sign.java.lang.String
getDecimalSeparatorString()
Returns the string used for decimal sign.char
getDigit()
Returns the character used for a digit in a pattern.char[]
getDigits()
Returns the array of characters used as digits, in order from 0 through 9java.lang.String[]
getDigitStrings()
Returns the array of strings used as digits, in order from 0 through 9java.lang.String[]
getDigitStringsLocal()
Deprecated.This API is ICU internal only.java.lang.String
getExponentMultiplicationSign()
Returns the multiplication signjava.lang.String
getExponentSeparator()
Returns the string used to separate the mantissa from the exponent.char
getGroupingSeparator()
Returns the character used for grouping separator.java.lang.String
getGroupingSeparatorString()
Returns the string used for grouping separator.java.lang.String
getInfinity()
Returns the String used to represent infinity.static DecimalFormatSymbols
getInstance()
Returns a DecimalFormatSymbols instance for the default locale.static DecimalFormatSymbols
getInstance(ULocale locale)
Returns a DecimalFormatSymbols instance for the given locale.static DecimalFormatSymbols
getInstance(java.util.Locale locale)
Returns a DecimalFormatSymbols instance for the given locale.java.lang.String
getInternationalCurrencySymbol()
Returns the international string denoting the local currency.java.util.Locale
getLocale()
Returns the locale for which this object was constructed.ULocale
getLocale(ULocale.Type type)
Returns the locale that was used to create this object, or null.char
getMinusSign()
Returns the character used to represent minus sign.java.lang.String
getMinusSignString()
Returns the string used to represent minus sign.char
getMonetaryDecimalSeparator()
Returns the monetary decimal separator.java.lang.String
getMonetaryDecimalSeparatorString()
Returns the monetary decimal separator string.char
getMonetaryGroupingSeparator()
Returns the monetary grouping separator.java.lang.String
getMonetaryGroupingSeparatorString()
Returns the monetary grouping separator.java.lang.String
getNaN()
Returns the String used to represent NaN.char
getPadEscape()
Returns the character used to pad numbers out to a specified width.java.lang.String
getPatternForCurrencySpacing(int itemType, boolean beforeCurrency)
Returns the desired currency spacing value.char
getPatternSeparator()
Returns the character used to separate positive and negative subpatterns in a pattern.char
getPercent()
Returns the character used for percent sign.java.lang.String
getPercentString()
Returns the string used for percent sign.char
getPerMill()
Returns the character used for mille percent sign.java.lang.String
getPerMillString()
Returns the string used for permille sign.char
getPlusSign()
Returns the localized plus sign.java.lang.String
getPlusSignString()
Returns the string used to represent plus sign.char
getSignificantDigit()
Returns the character used to represent a significant digit in a pattern.ULocale
getULocale()
Returns the locale for which this object was constructed.char
getZeroDigit()
Returns the character used for zero.int
hashCode()
private void
initialize(ULocale locale, NumberingSystem ns)
Initializes the symbols from the locale data.private void
initSpacingInfo(CurrencyData.CurrencySpacingInfo spcInfo)
private static DecimalFormatSymbols.CacheData
loadData(ULocale locale)
private void
readObject(java.io.ObjectInputStream stream)
Reads the default serializable fields, then ifserialVersionOnStream
is less than 1, initializemonetarySeparator
to be the same asdecimalSeparator
andexponential
to be 'E'.void
setApproximatelySignString(java.lang.String approximatelySignString)
Deprecated.This API is for technology preview only.void
setCurrency(Currency currency)
Sets the currency.private void
setCurrencyOrNull(Currency currency, CurrencyData.CurrencyDisplayInfo displayInfo)
void
setCurrencySymbol(java.lang.String currency)
Sets the string denoting the local currency.void
setDecimalSeparator(char decimalSeparator)
Sets the character used for decimal sign.void
setDecimalSeparatorString(java.lang.String decimalSeparatorString)
Sets the string used for decimal sign.void
setDigit(char digit)
Sets the character used for a digit in a pattern.void
setDigitStrings(java.lang.String[] digitStrings)
Sets the array of strings used as digits, in order from 0 through 9void
setExponentMultiplicationSign(java.lang.String exponentMultiplicationSign)
Sets the multiplication signvoid
setExponentSeparator(java.lang.String exp)
Sets the string used to separate the mantissa from the exponent.void
setGroupingSeparator(char groupingSeparator)
Sets the character used for grouping separator.void
setGroupingSeparatorString(java.lang.String groupingSeparatorString)
Sets the string used for grouping separator.void
setInfinity(java.lang.String infinity)
Sets the String used to represent infinity.void
setInternationalCurrencySymbol(java.lang.String currency)
Sets the international string denoting the local currency.(package private) void
setLocale(ULocale valid, ULocale actual)
Sets information about the locales that were used to create this object.void
setMinusSign(char minusSign)
Sets the character used to represent minus sign.void
setMinusSignString(java.lang.String minusSignString)
Sets the string used to represent minus sign.void
setMonetaryDecimalSeparator(char sep)
Sets the monetary decimal separator.void
setMonetaryDecimalSeparatorString(java.lang.String sep)
Sets the monetary decimal separator string.void
setMonetaryGroupingSeparator(char sep)
Sets the monetary grouping separator.void
setMonetaryGroupingSeparatorString(java.lang.String sep)
Sets the monetary grouping separator string.void
setNaN(java.lang.String NaN)
Sets the String used to represent NaN.void
setPadEscape(char c)
Sets the character used to pad numbers out to a specified width.void
setPatternForCurrencySpacing(int itemType, boolean beforeCurrency, java.lang.String pattern)
Sets the indicated currency spacing pattern or value.void
setPatternSeparator(char patternSeparator)
Sets the character used to separate positive and negative subpatterns in a pattern.void
setPercent(char percent)
Sets the character used for percent sign.void
setPercentString(java.lang.String percentString)
Sets the string used for percent sign.void
setPerMill(char perMill)
Sets the character used for mille percent sign.void
setPerMillString(java.lang.String perMillString)
Sets the string used for permille sign.void
setPlusSign(char plus)
Sets the localized plus sign.void
setPlusSignString(java.lang.String plusSignString)
Sets the localized plus sign string.void
setSignificantDigit(char sigDigit)
Sets the character used to represent a significant digit in a pattern.void
setZeroDigit(char zeroDigit)
Sets the character used for zero.
-
-
-
Field Detail
-
CURRENCY_SPC_CURRENCY_MATCH
public static final int CURRENCY_SPC_CURRENCY_MATCH
Indicates the currency match pattern used ingetPatternForCurrencySpacing(int, boolean)
.- See Also:
- Constant Field Values
-
CURRENCY_SPC_SURROUNDING_MATCH
public static final int CURRENCY_SPC_SURROUNDING_MATCH
Indicates the surrounding match pattern used ingetPatternForCurrencySpacing(int, boolean)
.- See Also:
- Constant Field Values
-
CURRENCY_SPC_INSERT
public static final int CURRENCY_SPC_INSERT
Indicates the insertion value used ingetPatternForCurrencySpacing(int, boolean)
.- See Also:
- Constant Field Values
-
currencySpcBeforeSym
private java.lang.String[] currencySpcBeforeSym
-
currencySpcAfterSym
private java.lang.String[] currencySpcAfterSym
-
SYMBOL_KEYS
private static final java.lang.String[] SYMBOL_KEYS
List of field names to be loaded from the data files. The indices of each name into the array correspond to the position of that item in the numberElements array.
-
DEF_DIGIT_STRINGS_ARRAY
private static final java.lang.String[] DEF_DIGIT_STRINGS_ARRAY
-
DEF_DIGIT_CHARS_ARRAY
private static final char[] DEF_DIGIT_CHARS_ARRAY
-
DEF_DECIMAL_SEPARATOR
private static final char DEF_DECIMAL_SEPARATOR
- See Also:
- Constant Field Values
-
DEF_GROUPING_SEPARATOR
private static final char DEF_GROUPING_SEPARATOR
- See Also:
- Constant Field Values
-
DEF_PERCENT
private static final char DEF_PERCENT
- See Also:
- Constant Field Values
-
DEF_MINUS_SIGN
private static final char DEF_MINUS_SIGN
- See Also:
- Constant Field Values
-
DEF_PLUS_SIGN
private static final char DEF_PLUS_SIGN
- See Also:
- Constant Field Values
-
DEF_PERMILL
private static final char DEF_PERMILL
- See Also:
- Constant Field Values
-
SYMBOL_DEFAULTS
private static final java.lang.String[] SYMBOL_DEFAULTS
List of default values for the symbols.
-
LATIN_NUMBERING_SYSTEM
private static final java.lang.String LATIN_NUMBERING_SYSTEM
Constants for path names in the data bundles.- See Also:
- Constant Field Values
-
NUMBER_ELEMENTS
private static final java.lang.String NUMBER_ELEMENTS
- See Also:
- Constant Field Values
-
SYMBOLS
private static final java.lang.String SYMBOLS
- See Also:
- Constant Field Values
-
zeroDigit
private char zeroDigit
Character used for zero. This remains only for backward compatibility purposes. The digits array below is now used to actively store the digits.- See Also:
getZeroDigit()
-
digits
private char[] digits
Array of characters used for the digits 0-9 in order.
-
digitStrings
private java.lang.String[] digitStrings
Array of Strings used for the digits 0-9 in order.
-
codePointZero
private transient int codePointZero
Dealing with code points is faster than dealing with strings when formatting. Because of this, we maintain a value containing the zero code point that is used whenever digitStrings represents a sequence of ten code points in order.If the value stored here is positive, it means that the code point stored in this value corresponds to the digitStrings array, and codePointZero can be used instead of the digitStrings array for the purposes of efficient formatting; if -1, then digitStrings does *not* contain a sequence of code points, and it must be used directly.
It is assumed that codePointZero always shadows the value in digitStrings. codePointZero should never be set directly; rather, it should be updated only when digitStrings mutates. That is, the flow of information is digitStrings -> codePointZero, not the other way.
-
groupingSeparator
private char groupingSeparator
Character used for thousands separator.- See Also:
getGroupingSeparator()
-
groupingSeparatorString
private java.lang.String groupingSeparatorString
String used for thousands separator.
-
decimalSeparator
private char decimalSeparator
Character used for decimal sign.- See Also:
getDecimalSeparator()
-
decimalSeparatorString
private java.lang.String decimalSeparatorString
String used for decimal sign.
-
perMill
private char perMill
Character used for mille percent sign.- See Also:
getPerMill()
-
perMillString
private java.lang.String perMillString
String used for mille percent sign.
-
percent
private char percent
Character used for percent sign.- See Also:
getPercent()
-
percentString
private java.lang.String percentString
String used for percent sign.
-
digit
private char digit
Character used for a digit in a pattern.- See Also:
getDigit()
-
sigDigit
private char sigDigit
Character used for a significant digit in a pattern.- See Also:
getSignificantDigit()
-
patternSeparator
private char patternSeparator
Character used to separate positive and negative subpatterns in a pattern.- See Also:
getPatternSeparator()
-
infinity
private java.lang.String infinity
Character used to represent infinity.- See Also:
getInfinity()
-
NaN
private java.lang.String NaN
Character used to represent NaN.- See Also:
getNaN()
-
minusSign
private char minusSign
Character used to represent minus sign.- See Also:
getMinusSign()
-
minusString
private java.lang.String minusString
String versions of minus sign.- Since:
- ICU 52
-
plusSign
private char plusSign
The character used to indicate a plus sign.- Since:
- AlphaWorks
-
plusString
private java.lang.String plusString
String versions of plus sign.- Since:
- ICU 52
-
approximatelyString
private java.lang.String approximatelyString
The string used to indicate an approximately sign.- Since:
- ICU 69
-
currencySymbol
private java.lang.String currencySymbol
String denoting the local currency, e.g. "$".- See Also:
getCurrencySymbol()
-
intlCurrencySymbol
private java.lang.String intlCurrencySymbol
International string denoting the local currency, e.g. "USD".- See Also:
getInternationalCurrencySymbol()
-
monetarySeparator
private char monetarySeparator
The decimal separator character used when formatting currency values.- See Also:
getMonetaryDecimalSeparator()
-
monetarySeparatorString
private java.lang.String monetarySeparatorString
The decimal separator string used when formatting currency values.
-
monetaryGroupingSeparator
private char monetaryGroupingSeparator
The grouping separator character used when formatting currency values.- See Also:
getMonetaryGroupingSeparator()
-
monetaryGroupingSeparatorString
private java.lang.String monetaryGroupingSeparatorString
The grouping separator string used when formatting currency values.
-
exponential
private char exponential
The character used to distinguish the exponent in a number formatted in exponential notation, e.g. 'E' for a number such as "1.23E45".Note that this field has been superseded by
exponentSeparator
. It is retained for backward compatibility.
-
exponentSeparator
private java.lang.String exponentSeparator
The string used to separate the mantissa from the exponent. Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.Note that this supersedes the
exponential
field.- Since:
- AlphaWorks
-
padEscape
private char padEscape
The character used to indicate a padding character in a format, e.g., '*' in a pattern such as "$*_#,##0.00".- Since:
- AlphaWorks
-
requestedLocale
private java.util.Locale requestedLocale
The locale for which this object was constructed. Set to the default locale for objects resurrected from old streams.- Since:
- ICU 2.2
-
ulocale
private ULocale ulocale
The requested ULocale. We keep the old locale for serialization compatibility.- Since:
- ICU 3.2
-
exponentMultiplicationSign
private java.lang.String exponentMultiplicationSign
Exponent multiplication sign. e.g "x"- Since:
- ICU 54
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
currentSerialVersion
private static final int currentSerialVersion
- See Also:
- Constant Field Values
-
serialVersionOnStream
private int serialVersionOnStream
Describes the version ofDecimalFormatSymbols
present on the stream. Possible values are:- 0 (or uninitialized): versions prior to JDK 1.1.6.
- 1: Versions written by JDK 1.1.6 or later, which includes
two new fields:
monetarySeparator
andexponential
. - 2: Version for AlphaWorks. Adds padEscape, exponentSeparator, and plusSign.
- 3: Version for ICU 2.2, which adds locale.
- 4: Version for ICU 3.2, which adds ulocale.
- 5: Version for ICU 3.6, which adds monetaryGroupingSeparator.
- 6: Version for ICU 4.2, which adds currencySpcBeforeSym and currencySpcAfterSym.
- 7: Version for ICU 52, which adds minusString and plusString.
DecimalFormatSymbols
, the most recent format (corresponding to the highest allowableserialVersionOnStream
) is always written.
-
cachedLocaleData
private static final CacheBase<ULocale,DecimalFormatSymbols.CacheData,java.lang.Void> cachedLocaleData
cache to hold the NumberElements of a Locale.
-
currencyPattern
private java.lang.String currencyPattern
-
validLocale
private ULocale validLocale
The most specific locale containing any resource data, or null.- See Also:
ULocale
-
actualLocale
private ULocale actualLocale
The locale containing data used to construct this object, or null.- See Also:
ULocale
-
currency
private transient Currency currency
-
-
Constructor Detail
-
DecimalFormatSymbols
public DecimalFormatSymbols()
Creates a DecimalFormatSymbols object for the defaultFORMAT
locale.- See Also:
ULocale.Category.FORMAT
-
DecimalFormatSymbols
public DecimalFormatSymbols(java.util.Locale locale)
Creates a DecimalFormatSymbols object for the given locale.- Parameters:
locale
- the locale
-
DecimalFormatSymbols
public DecimalFormatSymbols(ULocale locale)
Creates a DecimalFormatSymbols object for the given locale.- Parameters:
locale
- the locale
-
DecimalFormatSymbols
private DecimalFormatSymbols(java.util.Locale locale, NumberingSystem ns)
-
DecimalFormatSymbols
private DecimalFormatSymbols(ULocale locale, NumberingSystem ns)
-
-
Method Detail
-
getInstance
public static DecimalFormatSymbols getInstance()
Returns a DecimalFormatSymbols instance for the default locale.Note: Unlike
java.text.DecimalFormatSymbols#getInstance
, this method simply returnsnew com.ibm.icu.text.DecimalFormatSymbols()
. ICU currently does not supportDecimalFormatSymbolsProvider
, which was introduced in Java 6.- Returns:
- A DecimalFormatSymbols instance.
-
getInstance
public static DecimalFormatSymbols getInstance(java.util.Locale locale)
Returns a DecimalFormatSymbols instance for the given locale.Note: Unlike
java.text.DecimalFormatSymbols#getInstance
, this method simply returnsnew com.ibm.icu.text.DecimalFormatSymbols(locale)
. ICU currently does not supportDecimalFormatSymbolsProvider
, which was introduced in Java 6.- Parameters:
locale
- the locale.- Returns:
- A DecimalFormatSymbols instance.
-
getInstance
public static DecimalFormatSymbols getInstance(ULocale locale)
Returns a DecimalFormatSymbols instance for the given locale.Note: Unlike
java.text.DecimalFormatSymbols#getInstance
, this method simply returnsnew com.ibm.icu.text.DecimalFormatSymbols(locale)
. ICU currently does not supportDecimalFormatSymbolsProvider
, which was introduced in Java 6.- Parameters:
locale
- the locale.- Returns:
- A DecimalFormatSymbols instance.
-
forNumberingSystem
public static DecimalFormatSymbols forNumberingSystem(java.util.Locale locale, NumberingSystem ns)
Returns a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the givenNumberingSystem
.This method behaves equivalently to
getInstance()
called with a locale having a "numbers=xxxx" keyword specifying the numbering system by name.In this method, the NumberingSystem argument will be used even if the locale has its own "numbers=xxxx" keyword.
- Parameters:
locale
- the locale.ns
- the numbering system.- Returns:
- A DecimalFormatSymbols instance.
-
forNumberingSystem
public static DecimalFormatSymbols forNumberingSystem(ULocale locale, NumberingSystem ns)
Returns a DecimalFormatSymbols instance for the given locale with digits and symbols corresponding to the givenNumberingSystem
.This method behaves equivalently to
getInstance()
called with a locale having a "numbers=xxxx" keyword specifying the numbering system by name.In this method, the NumberingSystem argument will be used even if the locale has its own "numbers=xxxx" keyword.
- Parameters:
locale
- the locale.ns
- the numbering system.- Returns:
- A DecimalFormatSymbols instance.
-
getAvailableLocales
public static java.util.Locale[] getAvailableLocales()
Returns an array of all locales for which thegetInstance
methods of this class can return localized instances.Note: Unlike
java.text.DecimalFormatSymbols#getAvailableLocales
, this method simply returns the array ofLocale
s available for this class. ICU currently does not supportDecimalFormatSymbolsProvider
, which was introduced in Java 6.- Returns:
- An array of
Locale
s for which localizedDecimalFormatSymbols
instances are available.
-
getAvailableULocales
public static ULocale[] getAvailableULocales()
Returns an array of all locales for which thegetInstance
methods of this class can return localized instances.Note: Unlike
java.text.DecimalFormatSymbols#getAvailableLocales
, this method simply returns the array ofULocale
s available in this class. ICU currently does not supportDecimalFormatSymbolsProvider
, which was introduced in Java 6.- Returns:
- An array of
ULocale
s for which localizedDecimalFormatSymbols
instances are available.
-
getZeroDigit
public char getZeroDigit()
Returns the character used for zero. Different for Arabic, etc.- Returns:
- the character
-
getDigits
public char[] getDigits()
Returns the array of characters used as digits, in order from 0 through 9- Returns:
- The array
- See Also:
getDigitStrings()
-
setZeroDigit
public void setZeroDigit(char zeroDigit)
Sets the character used for zero.Note: This method propagates digit 1 to digit 9 by incrementing code point one by one.
- Parameters:
zeroDigit
- the zero character.
-
getDigitStrings
public java.lang.String[] getDigitStrings()
Returns the array of strings used as digits, in order from 0 through 9- Returns:
- The array of ten digit strings
- See Also:
setDigitStrings(String[])
-
getDigitStringsLocal
@Deprecated public java.lang.String[] getDigitStringsLocal()
Deprecated.This API is ICU internal only.Returns the array of strings used as digits, in order from 0 through 9 Package private method - doesn't create a defensively copy.WARNING: Mutating the returned array will cause undefined behavior. If you need to change the value of the array, use
getDigitStrings()
andsetDigitStrings(java.lang.String[])
instead.- Returns:
- the array of digit strings
-
getCodePointZero
@Deprecated public int getCodePointZero()
Deprecated.This API is ICU internal only.If the digit strings array corresponds to a sequence of increasing code points, this method returns the code point corresponding to the first entry in the digit strings array. If the digit strings array is not a sequence of increasing code points, returns -1.
-
setDigitStrings
public void setDigitStrings(java.lang.String[] digitStrings)
Sets the array of strings used as digits, in order from 0 through 9Note:
When the input array of digit strings contains any strings represented by multiple Java chars, then
getDigits()
will return the default digits ('0' - '9') andgetZeroDigit()
will return the default zero digit ('0').- Parameters:
digitStrings
- The array of digit strings. The length of the array must be exactly 10.- Throws:
java.lang.NullPointerException
- if thedigitStrings
is null.java.lang.IllegalArgumentException
- if the length of the array is not 10.- See Also:
getDigitStrings()
-
getSignificantDigit
public char getSignificantDigit()
Returns the character used to represent a significant digit in a pattern.- Returns:
- the significant digit pattern character
-
setSignificantDigit
public void setSignificantDigit(char sigDigit)
Sets the character used to represent a significant digit in a pattern.- Parameters:
sigDigit
- the significant digit pattern character
-
getGroupingSeparator
public char getGroupingSeparator()
Returns the character used for grouping separator. Different for French, etc.- Returns:
- the thousands character
-
setGroupingSeparator
public void setGroupingSeparator(char groupingSeparator)
Sets the character used for grouping separator. Different for French, etc.- Parameters:
groupingSeparator
- the thousands character- See Also:
setGroupingSeparatorString(String)
-
getGroupingSeparatorString
public java.lang.String getGroupingSeparatorString()
Returns the string used for grouping separator. Different for French, etc.- Returns:
- the grouping separator string
- See Also:
setGroupingSeparatorString(String)
-
setGroupingSeparatorString
public void setGroupingSeparatorString(java.lang.String groupingSeparatorString)
Sets the string used for grouping separator.Note: When the input grouping separator String is represented by multiple Java chars, then
getGroupingSeparator()
will return the default grouping separator character (',').- Parameters:
groupingSeparatorString
- the grouping separator string- Throws:
java.lang.NullPointerException
- ifgroupingSeparatorString
is null.- See Also:
getGroupingSeparatorString()
-
getDecimalSeparator
public char getDecimalSeparator()
Returns the character used for decimal sign. Different for French, etc.- Returns:
- the decimal character
-
setDecimalSeparator
public void setDecimalSeparator(char decimalSeparator)
Sets the character used for decimal sign. Different for French, etc.- Parameters:
decimalSeparator
- the decimal character
-
getDecimalSeparatorString
public java.lang.String getDecimalSeparatorString()
Returns the string used for decimal sign.- Returns:
- the decimal sign string
- See Also:
setDecimalSeparatorString(String)
-
setDecimalSeparatorString
public void setDecimalSeparatorString(java.lang.String decimalSeparatorString)
Sets the string used for decimal sign.Note: When the input decimal separator String is represented by multiple Java chars, then
getDecimalSeparator()
will return the default decimal separator character ('.').- Parameters:
decimalSeparatorString
- the decimal sign string- Throws:
java.lang.NullPointerException
- ifdecimalSeparatorString
is null.- See Also:
getDecimalSeparatorString()
-
getPerMill
public char getPerMill()
Returns the character used for mille percent sign. Different for Arabic, etc.- Returns:
- the mille percent character
-
setPerMill
public void setPerMill(char perMill)
Sets the character used for mille percent sign. Different for Arabic, etc.- Parameters:
perMill
- the mille percent character
-
getPerMillString
public java.lang.String getPerMillString()
Returns the string used for permille sign.- Returns:
- the permille string
- See Also:
setPerMillString(String)
-
setPerMillString
public void setPerMillString(java.lang.String perMillString)
Sets the string used for permille sign.Note: When the input permille String is represented by multiple Java chars, then
getPerMill()
will return the default permille character ('‰').- Parameters:
perMillString
- the permille string- Throws:
java.lang.NullPointerException
- ifperMillString
is null.- See Also:
getPerMillString()
-
getPercent
public char getPercent()
Returns the character used for percent sign. Different for Arabic, etc.- Returns:
- the percent character
-
setPercent
public void setPercent(char percent)
Sets the character used for percent sign. Different for Arabic, etc.- Parameters:
percent
- the percent character
-
getPercentString
public java.lang.String getPercentString()
Returns the string used for percent sign.- Returns:
- the percent string
- See Also:
setPercentString(String)
-
setPercentString
public void setPercentString(java.lang.String percentString)
Sets the string used for percent sign.Note: When the input grouping separator String is represented by multiple Java chars, then
getPercent()
will return the default percent sign character ('%').- Parameters:
percentString
- the percent string- Throws:
java.lang.NullPointerException
- ifpercentString
is null.- See Also:
getPercentString()
-
getDigit
public char getDigit()
Returns the character used for a digit in a pattern.- Returns:
- the digit pattern character
-
setDigit
public void setDigit(char digit)
Sets the character used for a digit in a pattern.- Parameters:
digit
- the digit pattern character
-
getPatternSeparator
public char getPatternSeparator()
Returns the character used to separate positive and negative subpatterns in a pattern.- Returns:
- the pattern separator character
-
setPatternSeparator
public void setPatternSeparator(char patternSeparator)
Sets the character used to separate positive and negative subpatterns in a pattern.- Parameters:
patternSeparator
- the pattern separator character
-
getInfinity
public java.lang.String getInfinity()
Returns the String used to represent infinity. Almost always left unchanged.- Returns:
- the Infinity string
-
setInfinity
public void setInfinity(java.lang.String infinity)
Sets the String used to represent infinity. Almost always left unchanged.- Parameters:
infinity
- the Infinity String
-
getNaN
public java.lang.String getNaN()
Returns the String used to represent NaN. Almost always left unchanged.- Returns:
- the NaN String
-
setNaN
public void setNaN(java.lang.String NaN)
Sets the String used to represent NaN. Almost always left unchanged.- Parameters:
NaN
- the NaN String
-
getMinusSign
public char getMinusSign()
Returns 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
-
setMinusSign
public void setMinusSign(char minusSign)
Sets 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
-
getMinusSignString
public java.lang.String getMinusSignString()
Returns the string used to represent minus sign.- Returns:
- the minus sign string
- See Also:
setMinusSignString(String)
-
setMinusSignString
public void setMinusSignString(java.lang.String minusSignString)
Sets the string used to represent minus sign.Note: When the input minus sign String is represented by multiple Java chars, then
getMinusSign()
will return the default minus sign character ('-').- Parameters:
minusSignString
- the minus sign string- Throws:
java.lang.NullPointerException
- ifminusSignString
is null.- See Also:
getGroupingSeparatorString()
-
getPlusSign
public char getPlusSign()
Returns the localized plus sign.- Returns:
- the plus sign, used in localized patterns and formatted strings
- See Also:
setPlusSign(char)
,setMinusSign(char)
,getMinusSign()
-
setPlusSign
public void setPlusSign(char plus)
Sets the localized plus sign.- Parameters:
plus
- the plus sign, used in localized patterns and formatted strings- See Also:
getPlusSign()
,setMinusSign(char)
,getMinusSign()
-
getPlusSignString
public java.lang.String getPlusSignString()
Returns the string used to represent plus sign.- Returns:
- the plus sign string
-
setPlusSignString
public void setPlusSignString(java.lang.String plusSignString)
Sets the localized plus sign string.Note: When the input plus sign String is represented by multiple Java chars, then
getPlusSign()
will return the default plus sign character ('+').- Parameters:
plusSignString
- the plus sign string, used in localized patterns and formatted strings- Throws:
java.lang.NullPointerException
- ifplusSignString
is null.- See Also:
getPlusSignString()
-
getApproximatelySignString
@Deprecated public java.lang.String getApproximatelySignString()
Deprecated.This API is for technology preview only.
-
setApproximatelySignString
@Deprecated public void setApproximatelySignString(java.lang.String approximatelySignString)
Deprecated.This API is for technology preview only.
-
getCurrencySymbol
public java.lang.String getCurrencySymbol()
Returns the string denoting the local currency.- Returns:
- the local currency String.
-
setCurrencySymbol
public void setCurrencySymbol(java.lang.String currency)
Sets the string denoting the local currency.- Parameters:
currency
- the local currency String.
-
getInternationalCurrencySymbol
public java.lang.String getInternationalCurrencySymbol()
Returns the international string denoting the local currency.- Returns:
- the international string denoting the local currency
-
setInternationalCurrencySymbol
public void setInternationalCurrencySymbol(java.lang.String currency)
Sets the international string denoting the local currency.- Parameters:
currency
- the international string denoting the local currency.
-
getCurrency
public Currency getCurrency()
Returns the currency symbol, forgetCurrency()
API compatibility only. ICU clients should use the Currency API directly.- Returns:
- the currency used, or null
-
setCurrency
public void setCurrency(Currency currency)
Sets the currency.Note: 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:
java.lang.NullPointerException
- ifcurrency
is null- See Also:
setCurrencySymbol(java.lang.String)
,setInternationalCurrencySymbol(java.lang.String)
-
setCurrencyOrNull
private void setCurrencyOrNull(Currency currency, CurrencyData.CurrencyDisplayInfo displayInfo)
-
getMonetaryDecimalSeparator
public char getMonetaryDecimalSeparator()
Returns the monetary decimal separator.- Returns:
- the monetary decimal separator character
-
setMonetaryDecimalSeparator
public void setMonetaryDecimalSeparator(char sep)
Sets the monetary decimal separator.- Parameters:
sep
- the monetary decimal separator character
-
getMonetaryDecimalSeparatorString
public java.lang.String getMonetaryDecimalSeparatorString()
Returns the monetary decimal separator string.- Returns:
- the monetary decimal separator string
- See Also:
setMonetaryDecimalSeparatorString(String)
-
setMonetaryDecimalSeparatorString
public void setMonetaryDecimalSeparatorString(java.lang.String sep)
Sets the monetary decimal separator string.Note: When the input monetary decimal separator String is represented by multiple Java chars, then
getMonetaryDecimalSeparatorString()
will return the default monetary decimal separator character ('.').- Parameters:
sep
- the monetary decimal separator string- Throws:
java.lang.NullPointerException
- ifsep
is null.- See Also:
getMonetaryDecimalSeparatorString()
-
getMonetaryGroupingSeparator
public char getMonetaryGroupingSeparator()
Returns the monetary grouping separator.- Returns:
- the monetary grouping separator character
-
setMonetaryGroupingSeparator
public void setMonetaryGroupingSeparator(char sep)
Sets the monetary grouping separator.- Parameters:
sep
- the monetary grouping separator character
-
getMonetaryGroupingSeparatorString
public java.lang.String getMonetaryGroupingSeparatorString()
Returns the monetary grouping separator.- Returns:
- the monetary grouping separator string
- See Also:
setMonetaryGroupingSeparatorString(String)
-
setMonetaryGroupingSeparatorString
public void setMonetaryGroupingSeparatorString(java.lang.String sep)
Sets the monetary grouping separator string.Note: When the input grouping separator String is represented by multiple Java chars, then
getMonetaryGroupingSeparator()
will return the default monetary grouping separator character (',').- Parameters:
sep
- the monetary grouping separator string- Throws:
java.lang.NullPointerException
- ifsep
is null.- See Also:
getMonetaryGroupingSeparatorString()
-
getCurrencyPattern
@Deprecated public java.lang.String getCurrencyPattern()
Deprecated.This API is for ICU internal use onlyInternal API for NumberFormat- Returns:
- String currency pattern string
-
getExponentMultiplicationSign
public java.lang.String getExponentMultiplicationSign()
Returns the multiplication sign
-
setExponentMultiplicationSign
public void setExponentMultiplicationSign(java.lang.String exponentMultiplicationSign)
Sets the multiplication sign
-
getExponentSeparator
public java.lang.String getExponentSeparator()
Returns 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)
-
setExponentSeparator
public void setExponentSeparator(java.lang.String exp)
Sets 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()
-
getPadEscape
public char getPadEscape()
Returns 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()
-
setPadEscape
public void setPadEscape(char c)
Sets 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.
-
getPatternForCurrencySpacing
public java.lang.String getPatternForCurrencySpacing(int itemType, boolean beforeCurrency)
Returns the desired currency spacing value. Original values come from ICU's CLDR data based on the locale provided during construction, and can be null. These values govern what and when text is inserted between a currency code/name/symbol and the currency amount when formatting money.For more information, see UTS#35 section 5.10.2.
- Parameters:
itemType
- one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH or CURRENCY_SPC_INSERTbeforeCurrency
- true to get thebeforeCurrency
values, false to get theafterCurrency
values.- Returns:
- the value, or null.
- See Also:
setPatternForCurrencySpacing(int, boolean, String)
-
setPatternForCurrencySpacing
public void setPatternForCurrencySpacing(int itemType, boolean beforeCurrency, java.lang.String pattern)
Sets the indicated currency spacing pattern or value. SeegetPatternForCurrencySpacing(int, boolean)
for more information.Values for currency match and surrounding match must be
UnicodeSet
patterns. Values for insert can be any string.Note: ICU4J does not currently use this information.
- Parameters:
itemType
- one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH or CURRENCY_SPC_INSERTbeforeCurrency
- true if the pattern is for before the currency symbol. false if the pattern is for after it.pattern
- string to override current setting; can be null.- See Also:
getPatternForCurrencySpacing(int, boolean)
-
getLocale
public java.util.Locale getLocale()
Returns the locale for which this object was constructed.- Returns:
- the locale for which this object was constructed
-
getULocale
public ULocale getULocale()
Returns the locale for which this object was constructed.- Returns:
- the locale for which this object was constructed
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
initialize
private void initialize(ULocale locale, NumberingSystem ns)
Initializes the symbols from the locale data.
-
loadData
private static DecimalFormatSymbols.CacheData loadData(ULocale locale)
-
initSpacingInfo
private void initSpacingInfo(CurrencyData.CurrencySpacingInfo spcInfo)
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Reads the default serializable fields, then ifserialVersionOnStream
is less than 1, initializemonetarySeparator
to be the same asdecimalSeparator
andexponential
to be 'E'. Finally, sets serialVersionOnStream back to the maximum allowed value so that default serialization will work properly if this object is streamed out again.- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
getLocale
public final ULocale getLocale(ULocale.Type type)
Returns 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: The actual locale is returned correctly, but the valid locale is not, in most cases.
- Parameters:
type
- type of information requested, eitherULocale.VALID_LOCALE
orULocale.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
-
setLocale
final void setLocale(ULocale valid, ULocale actual)
Sets information about the locales that were used to create this object. If the object was not constructed from locale data, both arguments should be set to null. Otherwise, neither should be null. The actual locale must be at the same level or less specific than the valid locale. This method is intended for use by factories or other entities that create objects of this class.- Parameters:
valid
- the most specific locale containing any resource data, or nullactual
- the locale containing data used to construct this object, or null- See Also:
ULocale
,ULocale.VALID_LOCALE
,ULocale.ACTUAL_LOCALE
-
-