Serializable, Cloneablepublic class DecimalFormatSymbols extends Object implements Cloneable, Serializable
DecimalFormatSymbols. Methods, fields, and other functionality specific to ICU are labeled '[icu]'.
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.Locale,
DecimalFormat,
序列化表格| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
CURRENCY_SPC_CURRENCY_MATCH |
[icu] Indicates the currency match pattern used in
getPatternForCurrencySpacing(int, boolean). |
static int |
CURRENCY_SPC_INSERT |
[icu] Indicates the insertion value used in
getPatternForCurrencySpacing(int, boolean). |
static int |
CURRENCY_SPC_SURROUNDING_MATCH |
[icu] Indicates the surrounding match pattern used in
getPatternForCurrencySpacing(int, boolean). |
| 构造器 | 说明 |
|---|---|
DecimalFormatSymbols() |
Creates a DecimalFormatSymbols object for the default
FORMAT locale. |
DecimalFormatSymbols(Locale locale) |
Creates a DecimalFormatSymbols object for the given locale.
|
DecimalFormatSymbols(ULocale locale) |
[icu] Creates a DecimalFormatSymbols object for the given locale.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Object |
clone() |
Creates and returns a copy of this object.
|
boolean |
equals(Object obj) |
Indicates whether some other object is "equal to" this one.
|
static DecimalFormatSymbols |
forNumberingSystem(Locale locale,
NumberingSystem ns) |
[icu] Returns a DecimalFormatSymbols instance for the given locale with digits and symbols
corresponding to the given
NumberingSystem. |
static DecimalFormatSymbols |
forNumberingSystem(ULocale locale,
NumberingSystem ns) |
[icu] Returns a DecimalFormatSymbols instance for the given locale with digits and symbols
corresponding to the given
NumberingSystem. |
static Locale[] |
getAvailableLocales() |
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
DecimalFormatSymbols#getCurrency() API
compatibility only. |
String |
getCurrencyPattern() |
已过时。
This API is for ICU internal use only
|
String |
getCurrencySymbol() |
Returns the string denoting the local currency.
|
char |
getDecimalSeparator() |
Returns the character used for decimal sign.
|
String |
getDecimalSeparatorString() |
[icu] 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 9
|
String[] |
getDigitStrings() |
[icu] Returns the array of strings used as digits, in order from 0 through 9
|
String |
getExponentMultiplicationSign() |
Returns the multiplication sign
|
String |
getExponentSeparator() |
[icu] Returns the string used to separate the mantissa from the exponent.
|
char |
getGroupingSeparator() |
Returns the character used for grouping separator.
|
String |
getGroupingSeparatorString() |
[icu] Returns the string used for grouping separator.
|
String |
getInfinity() |
Returns the String used to represent infinity.
|
static DecimalFormatSymbols |
getInstance() |
Returns a DecimalFormatSymbols instance for the default locale.
|
static DecimalFormatSymbols |
getInstance(Locale locale) |
Returns a DecimalFormatSymbols instance for the given locale.
|
static DecimalFormatSymbols |
getInstance(ULocale locale) |
Returns a DecimalFormatSymbols instance for the given locale.
|
String |
getInternationalCurrencySymbol() |
Returns the international string denoting the local currency.
|
Locale |
getLocale() |
Returns the locale for which this object was constructed.
|
char |
getMinusSign() |
Returns the character used to represent minus sign.
|
String |
getMinusSignString() |
[icu] Returns the string used to represent minus sign.
|
char |
getMonetaryDecimalSeparator() |
Returns the monetary decimal separator.
|
String |
getMonetaryDecimalSeparatorString() |
[icu] Returns the monetary decimal separator string.
|
char |
getMonetaryGroupingSeparator() |
[icu] Returns the monetary grouping separator.
|
String |
getMonetaryGroupingSeparatorString() |
[icu] Returns the monetary grouping separator.
|
String |
getNaN() |
Returns the String used to represent NaN.
|
char |
getPadEscape() |
[icu] Returns the character used to pad numbers out to a specified width.
|
String |
getPatternForCurrencySpacing(int itemType,
boolean beforeCurrency) |
[icu] 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.
|
String |
getPercentString() |
[icu] Returns the string used for percent sign.
|
char |
getPerMill() |
Returns the character used for mille percent sign.
|
String |
getPerMillString() |
[icu] Returns the string used for permille sign.
|
char |
getPlusSign() |
[icu] Returns the localized plus sign.
|
String |
getPlusSignString() |
[icu] 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() |
Returns a hash code value for the object.
|
void |
setCurrency(Currency currency) |
Sets the currency.
|
void |
setCurrencySymbol(String currency) |
Sets the string denoting the local currency.
|
void |
setDecimalSeparator(char decimalSeparator) |
Sets the character used for decimal sign.
|
void |
setDecimalSeparatorString(String decimalSeparatorString) |
[icu] Sets the string used for decimal sign.
|
void |
setDigit(char digit) |
Sets the character used for a digit in a pattern.
|
void |
setDigitStrings(String[] digitStrings) |
[icu] Sets the array of strings used as digits, in order from 0 through 9
|
void |
setExponentMultiplicationSign(String exponentMultiplicationSign) |
Sets the multiplication sign
|
void |
setExponentSeparator(String exp) |
[icu] Sets the string used to separate the mantissa from the exponent.
|
void |
setGroupingSeparator(char groupingSeparator) |
Sets the character used for grouping separator.
|
void |
setGroupingSeparatorString(String groupingSeparatorString) |
[icu] Sets the string used for grouping separator.
|
void |
setInfinity(String infinity) |
Sets the String used to represent infinity.
|
void |
setInternationalCurrencySymbol(String currency) |
Sets the international string denoting the local currency.
|
void |
setMinusSign(char minusSign) |
Sets the character used to represent minus sign.
|
void |
setMinusSignString(String minusSignString) |
[icu] Sets the string used to represent minus sign.
|
void |
setMonetaryDecimalSeparator(char sep) |
Sets the monetary decimal separator.
|
void |
setMonetaryDecimalSeparatorString(String sep) |
[icu] Sets the monetary decimal separator string.
|
void |
setMonetaryGroupingSeparator(char sep) |
[icu] Sets the monetary grouping separator.
|
void |
setMonetaryGroupingSeparatorString(String sep) |
[icu] Sets the monetary grouping separator string.
|
void |
setNaN(String NaN) |
Sets the String used to represent NaN.
|
void |
setPadEscape(char c) |
[icu] Sets the character used to pad numbers out to a specified width.
|
void |
setPatternForCurrencySpacing(int itemType,
boolean beforeCurrency,
String pattern) |
[icu] 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(String percentString) |
[icu] Sets the string used for percent sign.
|
void |
setPerMill(char perMill) |
Sets the character used for mille percent sign.
|
void |
setPerMillString(String perMillString) |
[icu] Sets the string used for permille sign.
|
void |
setPlusSign(char plus) |
[icu] Sets the localized plus sign.
|
void |
setPlusSignString(String plusSignString) |
[icu] 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.
|
public static final int CURRENCY_SPC_CURRENCY_MATCH
getPatternForCurrencySpacing(int, boolean).public static final int CURRENCY_SPC_INSERT
getPatternForCurrencySpacing(int, boolean).public static final int CURRENCY_SPC_SURROUNDING_MATCH
getPatternForCurrencySpacing(int, boolean).public DecimalFormatSymbols()
FORMAT locale.ULocale.Category.FORMATpublic DecimalFormatSymbols(Locale locale)
locale - the localepublic DecimalFormatSymbols(ULocale locale)
locale - the localepublic static DecimalFormatSymbols getInstance()
Note: Unlike
java.text.DecimalFormatSymbols#getInstance, this method simply returns
new ohos.global.icu.text.DecimalFormatSymbols(). ICU currently does not
support DecimalFormatSymbolsProvider, which was introduced in Java 6.
public static DecimalFormatSymbols getInstance(Locale locale)
Note: Unlike
java.text.DecimalFormatSymbols#getInstance, this method simply returns
new ohos.global.icu.text.DecimalFormatSymbols(locale). ICU currently does
not support DecimalFormatSymbolsProvider, which was introduced in Java
6.
locale - the locale.public static DecimalFormatSymbols getInstance(ULocale locale)
Note: Unlike
java.text.DecimalFormatSymbols#getInstance, this method simply returns
new ohos.global.icu.text.DecimalFormatSymbols(locale). ICU currently does
not support DecimalFormatSymbolsProvider, which was introduced in Java
6.
locale - the locale.public static DecimalFormatSymbols forNumberingSystem(Locale locale, NumberingSystem ns)
NumberingSystem.
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.
locale - the locale.ns - the numbering system.public static DecimalFormatSymbols forNumberingSystem(ULocale locale, NumberingSystem ns)
NumberingSystem.
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.
locale - the locale.ns - the numbering system.public static Locale[] getAvailableLocales()
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 currently
does not support DecimalFormatSymbolsProvider, which was introduced in
Java 6.
Locales for which localized
DecimalFormatSymbols instances are available.public char getZeroDigit()
public char[] getDigits()
getDigitStrings()public void setZeroDigit(char zeroDigit)
Note: This method propagates digit 1 to digit 9 by incrementing code point one by one.
zeroDigit - the zero character.public String[] getDigitStrings()
setDigitStrings(String[])public void setDigitStrings(String[] digitStrings)
Note:
When the input array of digit strings contains any strings
represented by multiple Java chars, then getDigits() will return
the default digits ('0' - '9') and getZeroDigit() will return the
default zero digit ('0').
digitStrings - The array of digit strings. The length of the array must be exactly 10.NullPointerException - if the digitStrings is null.IllegalArgumentException - if the length of the array is not 10.getDigitStrings()public char getSignificantDigit()
public void setSignificantDigit(char sigDigit)
sigDigit - the significant digit pattern characterpublic char getGroupingSeparator()
public void setGroupingSeparator(char groupingSeparator)
groupingSeparator - the thousands charactersetGroupingSeparatorString(String)public String getGroupingSeparatorString()
setGroupingSeparatorString(String)public void setGroupingSeparatorString(String groupingSeparatorString)
Note: When the input grouping separator String is represented
by multiple Java chars, then getGroupingSeparator() will
return the default grouping separator character (',').
groupingSeparatorString - the grouping separator stringNullPointerException - if groupingSeparatorString is null.getGroupingSeparatorString()public char getDecimalSeparator()
public void setDecimalSeparator(char decimalSeparator)
decimalSeparator - the decimal characterpublic String getDecimalSeparatorString()
setDecimalSeparatorString(String)public void setDecimalSeparatorString(String decimalSeparatorString)
Note: When the input decimal separator String is represented
by multiple Java chars, then getDecimalSeparator() will
return the default decimal separator character ('.').
decimalSeparatorString - the decimal sign stringNullPointerException - if decimalSeparatorString is null.getDecimalSeparatorString()public char getPerMill()
public void setPerMill(char perMill)
perMill - the mille percent characterpublic String getPerMillString()
setPerMillString(String)public void setPerMillString(String perMillString)
Note: When the input permille String is represented
by multiple Java chars, then getPerMill() will
return the default permille character ('‰').
perMillString - the permille stringNullPointerException - if perMillString is null.getPerMillString()public char getPercent()
public void setPercent(char percent)
percent - the percent characterpublic String getPercentString()
setPercentString(String)public void setPercentString(String percentString)
Note: When the input grouping separator String is represented
by multiple Java chars, then getPercent() will
return the default percent sign character ('%').
percentString - the percent stringNullPointerException - if percentString is null.getPercentString()public char getDigit()
public void setDigit(char digit)
digit - the digit pattern characterpublic char getPatternSeparator()
public void setPatternSeparator(char patternSeparator)
patternSeparator - the pattern separator characterpublic String getInfinity()
public void setInfinity(String infinity)
infinity - the Infinity Stringpublic String getNaN()
public void setNaN(String NaN)
NaN - the NaN Stringpublic char getMinusSign()
public void setMinusSign(char minusSign)
minusSign - the minus sign characterpublic String getMinusSignString()
setMinusSignString(String)public void setMinusSignString(String minusSignString)
Note: When the input minus sign String is represented
by multiple Java chars, then getMinusSign() will
return the default minus sign character ('-').
minusSignString - the minus sign stringNullPointerException - if minusSignString is null.getGroupingSeparatorString()public char getPlusSign()
setPlusSign(char),
setMinusSign(char),
getMinusSign()public void setPlusSign(char plus)
plus - the plus sign, used in localized patterns and formatted
stringsgetPlusSign(),
setMinusSign(char),
getMinusSign()public String getPlusSignString()
public void setPlusSignString(String plusSignString)
Note: When the input plus sign String is represented
by multiple Java chars, then getPlusSign() will
return the default plus sign character ('+').
plusSignString - the plus sign string, used in localized patterns and formatted
stringsNullPointerException - if plusSignString is null.getPlusSignString()public String getCurrencySymbol()
public void setCurrencySymbol(String currency)
currency - the local currency String.public String getInternationalCurrencySymbol()
public void setInternationalCurrencySymbol(String currency)
currency - the international string denoting the local currency.public Currency getCurrency()
DecimalFormatSymbols#getCurrency() API
compatibility only. ICU clients should use the Currency API directly.public void setCurrency(Currency 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.
currency - the new currency to be usedNullPointerException - if currency is nullsetCurrencySymbol(java.lang.String),
setInternationalCurrencySymbol(java.lang.String)public char getMonetaryDecimalSeparator()
public void setMonetaryDecimalSeparator(char sep)
sep - the monetary decimal separator characterpublic String getMonetaryDecimalSeparatorString()
setMonetaryDecimalSeparatorString(String)public void setMonetaryDecimalSeparatorString(String sep)
Note: When the input monetary decimal separator String is represented
by multiple Java chars, then getMonetaryDecimalSeparatorString() will
return the default monetary decimal separator character ('.').
sep - the monetary decimal separator stringNullPointerException - if sep is null.getMonetaryDecimalSeparatorString()public char getMonetaryGroupingSeparator()
public void setMonetaryGroupingSeparator(char sep)
sep - the monetary grouping separator characterpublic String getMonetaryGroupingSeparatorString()
setMonetaryGroupingSeparatorString(String)public void setMonetaryGroupingSeparatorString(String sep)
Note: When the input grouping separator String is represented
by multiple Java chars, then getMonetaryGroupingSeparator() will
return the default monetary grouping separator character (',').
sep - the monetary grouping separator stringNullPointerException - if sep is null.getMonetaryGroupingSeparatorString()@Deprecated public String getCurrencyPattern()
public String getExponentMultiplicationSign()
public void setExponentMultiplicationSign(String exponentMultiplicationSign)
public String getExponentSeparator()
setExponentSeparator(java.lang.String)public void setExponentSeparator(String exp)
exp - the localized exponent symbol, used in localized patterns
and formatted stringsgetExponentSeparator()public char getPadEscape()
setPadEscape(char),
DecimalFormat.getFormatWidth(),
DecimalFormat.getPadPosition(),
DecimalFormat.getPadCharacter()public void setPadEscape(char c)
public String getPatternForCurrencySpacing(int itemType, boolean beforeCurrency)
For more information, see UTS#35 section 5.10.2.
itemType - one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH
or CURRENCY_SPC_INSERTbeforeCurrency - true to get the beforeCurrency values, false
to get the afterCurrency values.setPatternForCurrencySpacing(int, boolean, String)public void setPatternForCurrencySpacing(int itemType,
boolean beforeCurrency,
String pattern)
getPatternForCurrencySpacing(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.
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.getPatternForCurrencySpacing(int, boolean)public Locale getLocale()
public ULocale getULocale()
public Object clone()
x, the expression:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
super.clone. If a class and all of its superclasses (except
Object) obey this convention, it will be the case that
x.clone().getClass() == x.getClass().
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by super.clone before returning it. Typically, this means
copying any mutable objects that comprise the internal "deep structure"
of the object being cloned and replacing the references to these
objects with references to the copies. If a class contains only
primitive fields or references to immutable objects, then it is usually
the case that no fields in the object returned by super.clone
need to be modified.
The method clone for class Object performs a
specific cloning operation. First, if the class of this object does
not implement the interface Cloneable, then a
CloneNotSupportedException is thrown. Note that all arrays
are considered to implement the interface Cloneable and that
the return type of the clone method of an array type T[]
is T[] where T is any reference or primitive type.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object does not itself implement the interface
Cloneable, so calling the clone method on an object
whose class is Object will result in throwing an
exception at run time.
public boolean equals(Object obj)
The equals method implements an equivalence relation
on non-null object references:
x, x.equals(x) should return
true.
x and y, x.equals(y)
should return true if and only if
y.equals(x) returns true.
x, y, and z, if
x.equals(y) returns true and
y.equals(z) returns true, then
x.equals(z) should return true.
x and y, multiple invocations of
x.equals(y) consistently return true
or consistently return false, provided no
information used in equals comparisons on the
objects is modified.
x,
x.equals(null) should return false.
The equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x and
y, this method returns true if and only
if x and y refer to the same object
(x == y has the value true).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode method, which states
that equal objects must have equal hash codes.
equals 在类中 Objectobj - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Object.hashCode(),
HashMappublic int hashCode()
HashMap.
The general contract of hashCode is:
hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode 在类中 ObjectObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)