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.
Create a DecimalFormatSymbols object for the default locale.
This constructor can only construct instances for the locales
supported by the Java runtime environment, not for those
supported by installed
DecimalFormatSymbolsProvider
implementations. For full locale coverage, use the
getInstance method.
Create a DecimalFormatSymbols object for the given locale.
This constructor can only construct instances for the locales
supported by the Java runtime environment, not for those
supported by installed
DecimalFormatSymbolsProvider
implementations. For full locale coverage, use the
getInstance method.
Returns an array of all locales for which the
getInstance methods of this class can return
localized instances.
The returned array represents the union of locales supported by the Java
runtime and by installed
DecimalFormatSymbolsProvider
implementations. It must contain at least a
Locale
instance equal to
Locale.US.
- Returns:
- An array of locales for which localized
DecimalFormatSymbols instances are available. - Since:
- 1.6
Gets the
DecimalFormatSymbols instance for the default
locale. This method provides access to
DecimalFormatSymbols
instances for locales supported by the Java runtime itself as well
as for those supported by installed
DecimalFormatSymbolsProvider implementations.
- Returns:
- a
DecimalFormatSymbols instance. - Since:
- 1.6
Gets the
DecimalFormatSymbols instance for the specified
locale. This method provides access to
DecimalFormatSymbols
instances for locales supported by the Java runtime itself as well
as for those supported by installed
DecimalFormatSymbolsProvider implementations.
if (providersInstance != null) { return providersInstance;
Gets the character used for zero. Different for Arabic, etc.
Sets the character used for zero. Different for Arabic, etc.
Gets the character used for thousands separator. Different for French, etc.
Sets the character used for thousands separator. Different for French, etc.
Gets the character used for decimal sign. Different for French, etc.
Sets the character used for decimal sign. Different for French, etc.
Gets the character used for per mille sign. Different for Arabic, etc.
Sets the character used for per mille sign. Different for Arabic, etc.
Gets the character used for percent sign. Different for Arabic, etc.
Sets the character used for percent sign. Different for Arabic, etc.
Gets the character used for a digit in a pattern.
Sets the character used for a digit in a pattern.
Gets the character used to separate positive and negative subpatterns
in a pattern.
Sets the character used to separate positive and negative subpatterns
in a pattern.
Gets the string used to represent infinity. Almost always left
unchanged.
Sets the string used to represent infinity. Almost always left
unchanged.
Gets the string used to represent "not a number". Almost always left
unchanged.
Sets the string used to represent "not a number". Almost always left
unchanged.
Gets the character used to represent minus sign. If no explicit
negative format is specified, one is formed by prefixing
minusSign to the positive format.
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.
Returns the currency symbol for the currency of these
DecimalFormatSymbols in their locale.
Sets the currency symbol for the currency of these
DecimalFormatSymbols in their locale.
Returns the ISO 4217 currency code of the currency of these
DecimalFormatSymbols.
Sets the ISO 4217 currency code of the currency of these
DecimalFormatSymbols.
If the currency code is valid (as defined by
Currency.getInstance),
this also sets the currency attribute to the corresponding Currency
instance and the currency symbol attribute to the currency's symbol
in the DecimalFormatSymbols' locale. If the currency code is not valid,
then the currency attribute is set to null and the currency symbol
attribute is not modified.
if (currencyCode != null) { Gets the currency of these DecimalFormatSymbols. May be null if the
currency symbol attribute was previously set to a value that's not
a valid ISO 4217 currency code.
- Returns:
- the currency used, or null
- Since:
- 1.4
Sets the currency of these DecimalFormatSymbols.
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.
Returns the monetary decimal separator.
Sets the monetary decimal separator.
Returns the character used to separate the mantissa from the exponent.
Returns the string used to separate the mantissa from the exponent.
Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
Sets the character used to separate the mantissa from the exponent.
Sets the string used to separate the mantissa from the exponent.
Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
if (obj == null) return false;
if (this == obj) return true;
Initializes the symbols from the FormatData resource bundle.
boolean needCacheUpdate = false;
NaN = numberElements[10];
Reads the default serializable fields, provides default values for objects
in older serial versions, and initializes non-serializable fields.
If
serialVersionOnStream
is less than 1, initializes
monetarySeparator to be
the same as
decimalSeparator and
exponential
to be 'E'.
If
serialVersionOnStream is less than 2,
initializes
localeto the root locale, and initializes
If
serialVersionOnStream is less than 3, it initializes
exponentialSeparator using
exponential.
Sets
serialVersionOnStream back to the maximum allowed value so that
default serialization will work properly if this object is streamed out again.
Initializes the currency from the intlCurrencySymbol field.
Character used for thousands separator.
Character used for decimal sign.
Character used for per mille sign.
Character used for percent sign.
Character used for a digit in a pattern.
Character used to separate positive and negative subpatterns
in a pattern.
String used to represent infinity.
String used to represent "not a number".
Character used to represent minus sign.
String denoting the local currency, e.g. "$".
ISO 4217 currency code denoting the local currency, e.g. "USD".
The decimal separator used when formatting currency values.
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 the public API provides no way to set this field,
even though it is supported by the implementation and the stream format.
The intent is that this will be added to the API in the future.
The string used to separate the mantissa from the exponent.
Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
If both exponential and exponentialSeparator
exist, this exponentialSeparator has the precedence.
The locale of these currency format symbols.
Describes the version of
DecimalFormatSymbols 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 include
two new fields:
monetarySeparator and exponential.
- 2: Versions written by J2SE 1.4 or later, which include a
new
locale field.
- 3: Versions written by J2SE 1.6 or later, which include a
new
exponentialSeparator field.
When streaming out a
DecimalFormatSymbols, the most recent format
(corresponding to the highest allowable
serialVersionOnStream)
is always written.
cache to hold the NumberElements and the Currency
of a Locale.
Obtains a DecimalFormatSymbols instance from a DecimalFormatSymbolsProvider
implementation.
assert params.length == 0;
return decimalFormatSymbolsProvider.getInstance(locale);