public class DecimalFormat extends NumberFormat
java.text.DecimalFormat
. Methods, fields, and other functionality specific to ICU are labeled '[icu]'.
IMPORTANT: New users are strongly encouraged to see if
NumberFormatter
fits their use case. Although not deprecated, this
class, DecimalFormat, is only provided for java.text.DecimalFormat compatibility.
DecimalFormat
is the primary
concrete subclass of NumberFormat
. It has a variety of features designed to make it
possible to parse and format numbers in any locale, including support for Western, Arabic, or
Indic digits. It supports different flavors of numbers, including integers ("123"), fixed-point
numbers ("123.4"), scientific notation ("1.23E4"), percentages ("12%"), and currency amounts
("$123.00", "USD123.00", "123.00 US dollars"). All of these flavors can be easily localized.
To obtain a number formatter for a specific locale (including the default locale), call one of
NumberFormat's factory methods such as NumberFormat.getInstance()
. Do not call
DecimalFormat constructors directly unless you know what you are doing.
DecimalFormat aims to comply with the specification UTS #35. Read the specification for more information on how all the properties in DecimalFormat fit together.
NOTE: Starting in ICU 60, there is a new set of APIs for localized number formatting that are designed to be an improvement over DecimalFormat. New users are discouraged from using DecimalFormat. For more information, see the package com.ibm.icu.number.
Customize settings on a DecimalFormat instance from the NumberFormat factory:
NumberFormat f = NumberFormat.getInstance(loc); if (f instanceof DecimalFormat) { ((DecimalFormat) f).setDecimalSeparatorAlwaysShown(true); ((DecimalFormat) f).setMinimumGroupingDigits(2); }
Quick and dirty print out a number using the localized number, currency, and percent format for each locale:
for (ULocale uloc : ULocale.getAvailableLocales()) { System.out.print(uloc + ":\t"); System.out.print(NumberFormat.getInstance(uloc).format(1.23)); System.out.print("\t"); System.out.print(NumberFormat.getCurrencyInstance(uloc).format(1.23)); System.out.print("\t"); System.out.print(NumberFormat.getPercentInstance(uloc).format(1.23)); System.out.println(); }
A DecimalFormat object encapsulates a set of properties and a set of symbols. Grouping size, rounding mode, and affixes are examples of properties. Locale digits and the characters used for grouping and decimal separators are examples of symbols.
To set a custom set of symbols, use setDecimalFormatSymbols(com.ibm.icu.text.DecimalFormatSymbols)
. Use the various other
setters in this class to set custom values for the properties.
DecimalFormat provides three main strategies to specify the position at which numbers should be rounded:
It is not possible to specify more than one rounding strategy. For example, setting a rounding increment in conjunction with significant digits results in undefined behavior.
It is also possible to specify the rounding mode to use. The default rounding mode is
"half even", which rounds numbers to their closest increment, with ties broken in favor of
trailing numbers being even. For more information, see setRoundingMode(int)
and the ICU
User Guide.
A pattern string is a way to serialize some of the available properties for decimal
formatting. However, not all properties are capable of being serialized into a pattern string;
see applyPattern(java.lang.String)
for more information.
Most users should not need to interface with pattern strings directly.
ICU DecimalFormat aims to follow the specification for pattern strings in UTS #35. Refer to that specification for more information on pattern string syntax.
pattern := subpattern (';' subpattern)? subpattern := prefix? number exponent? suffix? number := (integer ('.' fraction)?) | sigDigits prefix := '\u0000'..'\uFFFD' - specialCharacters suffix := '\u0000'..'\uFFFD' - specialCharacters integer := '#'* '0'* '0' fraction := '0'* '#'* sigDigits := '#'* '@' '@'* '#'* exponent := 'E' '+'? '0'* '0' padSpec := '*' padChar padChar := '\u0000'..'\uFFFD' - quote Notation: X* 0 or more instances of X X? 0 or 1 instances of X X|Y either X or Y C..D any character from C up to D, inclusive S-T characters in S, except those in T
The first subpattern is for positive numbers. The second (optional) subpattern is for negative numbers.
Not indicated in the BNF syntax above:
padSpec
may appear before the prefix, after the prefix,
before the suffix, after the suffix, or not at all.
DecimalFormat aims to be able to parse anything that it can output as a formatted string.
There are two primary parse modes: lenient and strict. Lenient mode should
be used if the goal is to parse user input to a number; strict mode should be used if the goal is
validation. The default is lenient mode. For more information, see setParseStrict(boolean)
.
DecimalFormat
parses all Unicode characters that represent decimal digits, as
defined by UCharacter.digit(int, int)
. In addition, DecimalFormat
also recognizes as
digits the ten consecutive characters starting with the localized zero digit defined in the
DecimalFormatSymbols
object. During formatting, the DecimalFormatSymbols
-based
digits are output.
Grouping separators are ignored in lenient mode (default). In strict mode, grouping separators must match the locale-specified grouping sizes.
When using parseCurrency(java.lang.CharSequence, java.text.ParsePosition)
, all currencies are accepted, not just the currency
currently set in the formatter. In addition, the formatter is able to parse every currency style
format for a particular locale no matter which style the formatter is constructed with. For
example, a formatter instance gotten from NumberFormat.getInstance(ULocale,
NumberFormat.CURRENCYSTYLE) can parse both "USD1.00" and "3.00 US dollars".
Whitespace characters (lenient mode) and control characters (lenient and strict mode), collectively called "ignorables", do not need to match in identity or quantity between the pattern string and the input string. For example, the pattern "# %" matches "35 %" (with a single space), "35%" (with no space), "35 %" (with a non-breaking space), and "35 %" (with multiple spaces). Arbitrary ignorables are also allowed at boundaries between the parts of the number: prefix, number, exponent separator, and suffix. Ignorable whitespace characters are those having the Unicode "blank" property for regular expressions, defined in UTS #18 Annex C, which is "horizontal" whitespace, like spaces and tabs, but not "vertical" whitespace, like line breaks. Ignorable control characters are those in the Unicode set [:Default_Ignorable_Code_Point:].
If parse(String, ParsePosition)
fails to parse a string, it returns null
and leaves the parse position unchanged. The convenience method NumberFormat.parse(String)
indicates
parse failure by throwing a ParseException
.
Under the hood, a state table parsing engine is used. To debug a parsing failure during development, use the following pattern to print details about the state table transitions:
com.ibm.icu.impl.number.Parse.DEBUGGING = true; df.parse("123.45", ppos); com.ibm.icu.impl.number.Parse.DEBUGGING = false;
Starting with ICU 59, instances of DecimalFormat are thread-safe.
Under the hood, DecimalFormat maintains an immutable formatter object that is rebuilt whenever any of the property setters are called. It is therefore best practice to call property setters only during construction and not when formatting numbers online.
Format
,
NumberFormat
,
Serialized FormModifier and Type | Class and Description |
---|---|
static interface |
DecimalFormat.PropertySetter
Deprecated.
This API is ICU internal only.
|
NumberFormat.Field, NumberFormat.NumberFormatFactory, NumberFormat.SimpleNumberFormatFactory
UFormat.SpanField
Modifier and Type | Field and Description |
---|---|
static int |
MINIMUM_GROUPING_DIGITS_AUTO
[icu] Constant for
setMinimumGroupingDigits(int) to specify display
grouping using the default strategy for all locales. |
static int |
MINIMUM_GROUPING_DIGITS_MIN2
[icu] Constant for
setMinimumGroupingDigits(int) to specify display
grouping using locale defaults, except do not show grouping on values smaller than
10000 (such that there is a minimum of two digits before the first separator). |
static int |
PAD_AFTER_PREFIX
[icu] Constant for
getPadPosition() and setPadPosition(int) to specify pad
characters inserted after the prefix. |
static int |
PAD_AFTER_SUFFIX
[icu] Constant for
getPadPosition() and setPadPosition(int) to specify pad
characters inserted after the suffix. |
static int |
PAD_BEFORE_PREFIX
[icu] Constant for
getPadPosition() and setPadPosition(int) to specify pad
characters inserted before the prefix. |
static int |
PAD_BEFORE_SUFFIX
[icu] Constant for
getPadPosition() and setPadPosition(int) to specify pad
characters inserted before the suffix. |
ACCOUNTINGCURRENCYSTYLE, CASHCURRENCYSTYLE, CURRENCYSTYLE, FRACTION_FIELD, INTEGER_FIELD, INTEGERSTYLE, ISOCURRENCYSTYLE, NUMBERSTYLE, PERCENTSTYLE, PLURALCURRENCYSTYLE, SCIENTIFICSTYLE, STANDARDCURRENCYSTYLE
Constructor and Description |
---|
DecimalFormat()
Creates a DecimalFormat based on the number pattern and symbols for the default locale.
|
DecimalFormat(String pattern)
Creates a DecimalFormat based on the given pattern, using symbols for the default locale.
|
DecimalFormat(String pattern,
DecimalFormatSymbols symbols)
Creates a DecimalFormat based on the given pattern and symbols.
|
DecimalFormat(String pattern,
DecimalFormatSymbols symbols,
CurrencyPluralInfo infoInput,
int style)
Creates a DecimalFormat based on the given pattern and symbols, with additional control over
the behavior of currency.
|
Modifier and Type | Method and Description |
---|---|
void |
applyLocalizedPattern(String localizedPattern)
Converts the given string to standard notation and then parses it using
applyPattern(java.lang.String) . |
void |
applyPattern(String pattern)
Parses the given pattern string and overwrites the settings specified in the pattern string.
|
boolean |
areSignificantDigitsUsed()
[icu] Returns whether significant digits are being used in rounding.
|
Object |
clone()
Overrides clone.
|
boolean |
equals(Object obj)
Tests for equality between this formatter and another formatter.
|
StringBuffer |
format(BigDecimal number,
StringBuffer result,
FieldPosition fieldPosition)
[icu] Formats a BigDecimal.
|
StringBuffer |
format(BigDecimal number,
StringBuffer result,
FieldPosition fieldPosition)
[icu] Formats an ICU BigDecimal.
|
StringBuffer |
format(BigInteger number,
StringBuffer result,
FieldPosition fieldPosition)
[icu] Formats a BigInteger.
|
StringBuffer |
format(CurrencyAmount currAmt,
StringBuffer result,
FieldPosition fieldPosition)
[icu] Formats a CurrencyAmount.
|
StringBuffer |
format(double number,
StringBuffer result,
FieldPosition fieldPosition)
Specialization of format.
|
StringBuffer |
format(long number,
StringBuffer result,
FieldPosition fieldPosition)
Specialization of format.
|
AttributedCharacterIterator |
formatToCharacterIterator(Object obj) |
Currency |
getCurrency()
Returns the currency used to display currency amounts.
|
CurrencyPluralInfo |
getCurrencyPluralInfo()
[icu] Returns the current instance of CurrencyPluralInfo.
|
Currency.CurrencyUsage |
getCurrencyUsage()
[icu] Returns the strategy for rounding currency amounts.
|
DecimalFormatSymbols |
getDecimalFormatSymbols()
Returns a copy of the decimal format symbols used by this formatter.
|
PluralRules.IFixedDecimal |
getFixedDecimal(double number)
Deprecated.
This API is ICU internal only.
|
int |
getFormatWidth()
Returns the minimum number of characters in formatted output.
|
int |
getGroupingSize()
Returns the primary grouping size in use.
|
MathContext |
getMathContext()
[icu] Returns the
MathContext being used to round numbers. |
MathContext |
getMathContextICU()
[icu] Returns the
MathContext being used to round numbers. |
int |
getMaximumFractionDigits()
Returns the effective maximum number of integer digits after the decimal separator.
|
int |
getMaximumIntegerDigits()
Returns the effective maximum number of digits before the decimal separator.
|
int |
getMaximumSignificantDigits()
[icu] Returns the effective maximum number of significant digits displayed.
|
byte |
getMinimumExponentDigits()
[icu] Returns the minimum number of digits printed in the exponent in scientific notation.
|
int |
getMinimumFractionDigits()
Returns the effective minimum number of integer digits after the decimal separator.
|
int |
getMinimumGroupingDigits()
[icu] Returns the minimum number of digits before grouping is triggered.
|
int |
getMinimumIntegerDigits()
Returns the effective minimum number of digits before the decimal separator.
|
int |
getMinimumSignificantDigits()
[icu] Returns the effective minimum number of significant digits displayed.
|
int |
getMultiplier()
Returns the multiplier being applied to numbers before they are formatted.
|
String |
getNegativePrefix()
Affixes: Gets the negative prefix string currently being used to format
numbers.
|
String |
getNegativeSuffix()
Affixes: Gets the negative suffix string currently being used to format
numbers.
|
char |
getPadCharacter()
[icu] Returns the character used for padding.
|
int |
getPadPosition()
[icu] Returns the position used for padding.
|
int |
getParseMaxDigits()
Deprecated.
Setting max parse digits has no effect since ICU4J 59.
|
String |
getPositivePrefix()
Affixes: Gets the positive prefix string currently being used to format
numbers.
|
String |
getPositiveSuffix()
Affixes: Gets the positive suffix string currently being used to format
numbers.
|
BigDecimal |
getRoundingIncrement()
[icu] Returns the increment to which numbers are being rounded.
|
int |
getRoundingMode()
Returns the rounding mode being used to round numbers.
|
int |
getSecondaryGroupingSize()
[icu] Returns the secondary grouping size in use.
|
int |
hashCode() |
boolean |
isDecimalPatternMatchRequired()
[icu] Returns whether the presence of a decimal point must match the pattern.
|
boolean |
isDecimalSeparatorAlwaysShown()
Returns whether the decimal separator is shown on integers.
|
boolean |
isExponentSignAlwaysShown()
[icu] Returns whether the sign (plus or minus) is always printed in scientific notation.
|
boolean |
isGroupingUsed()
Returns whether or not grouping separators are being printed in the output.
|
boolean |
isParseBigDecimal()
Returns whether
parse(java.lang.String, java.text.ParsePosition) will always return a BigDecimal. |
boolean |
isParseCaseSensitive()
[icu] Returns whether to force case (uppercase/lowercase) to match when parsing.
|
boolean |
isParseIntegerOnly()
Returns true if this format will parse numbers as integers only.
|
boolean |
isParseNoExponent()
[icu] Returns whether to ignore exponents when parsing.
|
boolean |
isParseStrict()
[icu] Returns whether strict parsing is in effect.
|
boolean |
isScientificNotation()
[icu] Returns whether scientific (exponential) notation is enabled on this formatter.
|
boolean |
isSignAlwaysShown()
[icu] Returns whether the sign is being shown on positive numbers.
|
Number |
parse(String text,
ParsePosition parsePosition)
Returns a Long if possible (e.g., within the range [Long.MIN_VALUE,
Long.MAX_VALUE] and with no decimals); otherwise, returns another type,
such as a BigDecimal, BigInteger, or Double.
|
CurrencyAmount |
parseCurrency(CharSequence text,
ParsePosition parsePosition)
Parses text from the given string as a CurrencyAmount.
|
void |
setCurrency(Currency currency)
Sets the currency to be used when formatting numbers.
|
void |
setCurrencyPluralInfo(CurrencyPluralInfo newInfo)
[icu] Sets a custom instance of CurrencyPluralInfo.
|
void |
setCurrencyUsage(Currency.CurrencyUsage usage)
[icu] Sets the currency-dependent strategy to use when rounding numbers.
|
void |
setDecimalFormatSymbols(DecimalFormatSymbols newSymbols)
Sets the decimal format symbols used by this formatter.
|
void |
setDecimalPatternMatchRequired(boolean value)
[icu] Parsing: This method is used to either require or
forbid the presence of a decimal point in the string being parsed (disabled by
default).
|
void |
setDecimalSeparatorAlwaysShown(boolean value)
Separators: Sets whether the decimal separator (a period in en-US) is
shown on integers.
|
void |
setExponentSignAlwaysShown(boolean expSignAlways)
[icu] Scientific Notation: Sets whether the sign (plus or minus) is always to
be shown in the exponent in scientific notation.
|
void |
setFormatWidth(int width)
Padding: Sets the minimum width of the string output by the formatting
pipeline.
|
void |
setGroupingSize(int width)
Grouping: Sets the primary grouping size (distance between grouping
separators) used when formatting large numbers.
|
void |
setGroupingUsed(boolean enabled)
Grouping: Sets whether grouping is to be used when formatting numbers.
|
void |
setMathContext(MathContext mathContext)
[icu] Rounding and Digit Limits: Sets the
MathContext used
to round numbers. |
void |
setMathContextICU(MathContext mathContextICU)
[icu] Rounding and Digit Limits: Overload of
setMathContext(java.math.MathContext) for
MathContext . |
void |
setMaximumFractionDigits(int value)
Rounding and Digit Limits: Sets the maximum number of digits to display after
the decimal separator.
|
void |
setMaximumIntegerDigits(int value)
Rounding and Digit Limits: Sets the maximum number of digits to display before
the decimal separator.
|
void |
setMaximumSignificantDigits(int value)
[icu] Rounding and Digit Limits: Sets the maximum number of significant
digits to be displayed.
|
void |
setMinimumExponentDigits(byte minExpDig)
[icu] Scientific Notation: Sets the minimum number of digits to be printed in
the exponent.
|
void |
setMinimumFractionDigits(int value)
Rounding and Digit Limits: Sets the minimum number of digits to display after
the decimal separator.
|
void |
setMinimumGroupingDigits(int number)
[icu] Sets the minimum number of digits that must be before the first grouping separator in
order for the grouping separator to be printed.
|
void |
setMinimumIntegerDigits(int value)
Rounding and Digit Limits: Sets the minimum number of digits to display before
the decimal separator.
|
void |
setMinimumSignificantDigits(int value)
[icu] Rounding and Digit Limits: Sets the minimum number of significant
digits to be displayed.
|
void |
setMultiplier(int multiplier)
Sets a number that will be used to multiply all numbers prior to formatting.
|
void |
setNegativePrefix(String prefix)
Affixes: Sets the string to prepend to negative numbers.
|
void |
setNegativeSuffix(String suffix)
Affixes: Sets the string to append to negative numbers.
|
void |
setPadCharacter(char padChar)
[icu] Padding: Sets the character used to pad numbers that are narrower than
the width specified in
setFormatWidth(int) . |
void |
setPadPosition(int padPos)
[icu] Padding: Sets the position where to insert the pad character when
narrower than the width specified in
setFormatWidth(int) . |
void |
setParseBigDecimal(boolean value)
Whether to make
parse(java.lang.String, java.text.ParsePosition) prefer returning a BigDecimal when
possible. |
void |
setParseCaseSensitive(boolean value)
[icu] Specifies whether parsing should require cases to match in affixes, exponent separators,
and currency codes.
|
void |
setParseIntegerOnly(boolean parseIntegerOnly)
Parsing: Sets whether to ignore the fraction part of a number when parsing
(defaults to false).
This is functionally equivalent to calling
setDecimalPatternMatchRequired(boolean) and a
pattern without a decimal point. |
void |
setParseMaxDigits(int maxDigits)
Deprecated.
Setting max parse digits has no effect since ICU4J 59.
|
void |
setParseNoExponent(boolean value)
[icu] Specifies whether to stop parsing when an exponent separator is encountered.
|
void |
setParseStrict(boolean parseStrict)
[icu] Sets whether strict parsing is in effect.
|
void |
setParseStrictMode(com.ibm.icu.impl.number.DecimalFormatProperties.ParseMode parseMode)
Deprecated.
This API is ICU internal only.
|
void |
setPositivePrefix(String prefix)
Affixes: Sets the string to prepend to positive numbers.
|
void |
setPositiveSuffix(String suffix)
Affixes: Sets the string to append to positive numbers.
|
void |
setProperties(DecimalFormat.PropertySetter func)
Deprecated.
This API is ICU internal only.
|
void |
setRoundingIncrement(BigDecimal increment)
[icu] Rounding and Digit Limits: Sets an increment, or interval, to which
numbers are rounded.
|
void |
setRoundingIncrement(BigDecimal increment)
[icu] Rounding and Digit Limits: Overload of
setRoundingIncrement(java.math.BigDecimal) . |
void |
setRoundingIncrement(double increment)
[icu] Rounding and Digit Limits: Overload of
setRoundingIncrement(java.math.BigDecimal) . |
void |
setRoundingMode(int roundingMode)
Rounding and Digit Limits: Sets the
RoundingMode used to round
numbers. |
void |
setScientificNotation(boolean useScientific)
[icu] Scientific Notation: Sets whether this formatter should print in
scientific (exponential) notation.
|
void |
setSecondaryGroupingSize(int width)
[icu] Grouping: Sets the secondary grouping size (distance between grouping
separators after the first separator) used when formatting large numbers.
|
void |
setSignAlwaysShown(boolean value)
Sets whether to always shown the plus sign ('+' in en) on positive numbers.
|
void |
setSignificantDigitsUsed(boolean useSignificantDigits)
[icu] Rounding and Digit Limits: Sets whether significant digits are to be
used in rounding.
|
String |
toLocalizedPattern()
Calls
toPattern() and converts the string to localized notation. |
LocalizedNumberFormatter |
toNumberFormatter()
Converts this DecimalFormat to a NumberFormatter.
|
String |
toPattern()
Serializes this formatter object to a decimal format pattern string.
|
String |
toString()
Returns the default value of toString() with extra DecimalFormat-specific information appended
to the end of the string.
|
format, format, format, format, format, format, format, getAvailableLocales, getAvailableULocales, getContext, getCurrencyInstance, getCurrencyInstance, getCurrencyInstance, getEffectiveCurrency, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getIntegerInstance, getNumberInstance, getNumberInstance, getNumberInstance, getPattern, getPattern, getPatternForStyle, getPatternForStyleAndNumberingSystem, getPercentInstance, getPercentInstance, getPercentInstance, getScientificInstance, getScientificInstance, getScientificInstance, parse, parseObject, registerFactory, setContext, unregister
format, parseObject
public static final int MINIMUM_GROUPING_DIGITS_AUTO
setMinimumGroupingDigits(int)
to specify display
grouping using the default strategy for all locales.setMinimumGroupingDigits(int)
,
MINIMUM_GROUPING_DIGITS_MIN2
,
Constant Field Valuespublic static final int MINIMUM_GROUPING_DIGITS_MIN2
setMinimumGroupingDigits(int)
to specify display
grouping using locale defaults, except do not show grouping on values smaller than
10000 (such that there is a minimum of two digits before the first separator).setMinimumGroupingDigits(int)
,
MINIMUM_GROUPING_DIGITS_AUTO
,
Constant Field Valuespublic static final int PAD_BEFORE_PREFIX
getPadPosition()
and setPadPosition(int)
to specify pad
characters inserted before the prefix.setPadPosition(int)
,
getPadPosition()
,
PAD_AFTER_PREFIX
,
PAD_BEFORE_SUFFIX
,
PAD_AFTER_SUFFIX
,
Constant Field Valuespublic static final int PAD_AFTER_PREFIX
getPadPosition()
and setPadPosition(int)
to specify pad
characters inserted after the prefix.setPadPosition(int)
,
getPadPosition()
,
PAD_BEFORE_PREFIX
,
PAD_BEFORE_SUFFIX
,
PAD_AFTER_SUFFIX
,
Constant Field Valuespublic static final int PAD_BEFORE_SUFFIX
getPadPosition()
and setPadPosition(int)
to specify pad
characters inserted before the suffix.setPadPosition(int)
,
getPadPosition()
,
PAD_BEFORE_PREFIX
,
PAD_AFTER_PREFIX
,
PAD_AFTER_SUFFIX
,
Constant Field Valuespublic static final int PAD_AFTER_SUFFIX
getPadPosition()
and setPadPosition(int)
to specify pad
characters inserted after the suffix.setPadPosition(int)
,
getPadPosition()
,
PAD_BEFORE_PREFIX
,
PAD_AFTER_PREFIX
,
PAD_BEFORE_SUFFIX
,
Constant Field Valuespublic DecimalFormat()
Most users should call the factory methods on NumberFormat, such as NumberFormat.getNumberInstance()
, which return localized formatter objects, instead of the
DecimalFormat constructors.
NumberFormat.getInstance()
,
NumberFormat.getNumberInstance()
,
NumberFormat.getCurrencyInstance()
,
NumberFormat.getPercentInstance()
,
ULocale.Category.FORMAT
public DecimalFormat(String pattern)
Most users should call the factory methods on NumberFormat, such as NumberFormat.getNumberInstance()
, which return localized formatter objects, instead of the
DecimalFormat constructors.
pattern
- A pattern string such as "#,##0.00" conforming to UTS
#35.IllegalArgumentException
- if the given pattern is invalid.NumberFormat.getInstance()
,
NumberFormat.getNumberInstance()
,
NumberFormat.getCurrencyInstance()
,
NumberFormat.getPercentInstance()
,
ULocale.Category.FORMAT
public DecimalFormat(String pattern, DecimalFormatSymbols symbols)
Most users should call the factory methods on NumberFormat, such as NumberFormat.getNumberInstance()
, which return localized formatter objects, instead of the
DecimalFormat constructors.
pattern
- A pattern string such as "#,##0.00" conforming to UTS
#35.symbols
- The set of symbols to be used.IllegalArgumentException
- if the given pattern is invalidNumberFormat.getInstance()
,
NumberFormat.getNumberInstance()
,
NumberFormat.getCurrencyInstance()
,
NumberFormat.getPercentInstance()
,
DecimalFormatSymbols
public DecimalFormat(String pattern, DecimalFormatSymbols symbols, CurrencyPluralInfo infoInput, int style)
CurrencyPluralInfo
object is used for customizing the
plural forms used for currency long names.
Most users should call the factory methods on NumberFormat, such as NumberFormat.getNumberInstance()
, which return localized formatter objects, instead of the
DecimalFormat constructors.
pattern
- a non-localized pattern stringsymbols
- the set of symbols to be usedinfoInput
- the information used for currency plural format, including currency plural
patterns and plural rules.style
- the decimal formatting style, it is one of the following values:
NumberFormat.NUMBERSTYLE; NumberFormat.CURRENCYSTYLE; NumberFormat.PERCENTSTYLE;
NumberFormat.SCIENTIFICSTYLE; NumberFormat.INTEGERSTYLE; NumberFormat.ISOCURRENCYSTYLE;
NumberFormat.PLURALCURRENCYSTYLE;public void applyPattern(String pattern)
setDecimalSeparatorAlwaysShown(boolean)
setExponentSignAlwaysShown(boolean)
setFormatWidth(int)
setGroupingSize(int)
setMultiplier(int)
(percent/permille)
setMaximumFractionDigits(int)
setMaximumIntegerDigits(int)
setMaximumSignificantDigits(int)
setMinimumExponentDigits(byte)
setMinimumFractionDigits(int)
setMinimumIntegerDigits(int)
setMinimumSignificantDigits(int)
setPadPosition(int)
setPadCharacter(char)
setRoundingIncrement(java.math.BigDecimal)
setSecondaryGroupingSize(int)
For more information on pattern strings, see UTS #35.
public void applyLocalizedPattern(String localizedPattern)
applyPattern(java.lang.String)
.
This method is provided for backwards compatibility and should not be used in new projects.
Localized notation means that instead of using generic placeholders in the pattern, you use the corresponding locale-specific characters instead. For example, in locale fr-FR, the period in the pattern "0.000" means "decimal" in standard notation (as it does in every other locale), but it means "grouping" in localized notation.
localizedPattern
- The pattern string in localized notation.public Object clone()
NumberFormat
clone
in class NumberFormat
public StringBuffer format(double number, StringBuffer result, FieldPosition fieldPosition)
format
in class NumberFormat
Format.format(Object, StringBuffer, FieldPosition)
public StringBuffer format(long number, StringBuffer result, FieldPosition fieldPosition)
format
in class NumberFormat
Format.format(Object, StringBuffer, FieldPosition)
public StringBuffer format(BigInteger number, StringBuffer result, FieldPosition fieldPosition)
format
in class NumberFormat
Format.format(Object, StringBuffer, FieldPosition)
public StringBuffer format(BigDecimal number, StringBuffer result, FieldPosition fieldPosition)
format
in class NumberFormat
Format.format(Object, StringBuffer, FieldPosition)
public StringBuffer format(BigDecimal number, StringBuffer result, FieldPosition fieldPosition)
format
in class NumberFormat
Format.format(Object, StringBuffer, FieldPosition)
public AttributedCharacterIterator formatToCharacterIterator(Object obj)
formatToCharacterIterator
in class Format
public StringBuffer format(CurrencyAmount currAmt, StringBuffer result, FieldPosition fieldPosition)
format
in class NumberFormat
Format.format(Object, StringBuffer, FieldPosition)
public Number parse(String text, ParsePosition parsePosition)
If IntegerOnly is set, will stop at a decimal point (or equivalent; e.g., for rational numbers "1 2/3", will stop after the 1).
Does not throw an exception; if no object can be parsed, index is unchanged!
For more detail on parsing, see the "Parsing" header in the class
documentation of DecimalFormat
.
parse
in class NumberFormat
NumberFormat.isParseIntegerOnly()
,
setParseBigDecimal(boolean)
,
Format.parseObject(String, ParsePosition)
public CurrencyAmount parseCurrency(CharSequence text, ParsePosition parsePosition)
parseCurrency
in class NumberFormat
text
- the text to parseparsePosition
- input-output position; on input, the position within
text to match; must have 0 <= pos.getIndex() < text.length();
on output, the position after the last matched character. If
the parse fails, the position in unchanged upon output.public DecimalFormatSymbols getDecimalFormatSymbols()
DecimalFormatSymbols
public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols)
newSymbols
- desired DecimalFormatSymbolsDecimalFormatSymbols
public String getPositivePrefix()
If the affix was specified via the pattern, the string returned by this method will have
locale symbols substituted in place of special characters according to the LDML specification.
If the affix was specified via setPositivePrefix(java.lang.String)
, the string will be returned
literally.
public void setPositivePrefix(String prefix)
Using this method overrides the affix specified via the pattern, and unlike the pattern, the string given to this method will be interpreted literally WITHOUT locale symbol substitutions.
prefix
- The literal string to prepend to positive numbers.public String getNegativePrefix()
If the affix was specified via the pattern, the string returned by this method will have
locale symbols substituted in place of special characters according to the LDML specification.
If the affix was specified via setNegativePrefix(java.lang.String)
, the string will be returned
literally.
public void setNegativePrefix(String prefix)
Using this method overrides the affix specified via the pattern, and unlike the pattern, the string given to this method will be interpreted literally WITHOUT locale symbol substitutions.
prefix
- The literal string to prepend to negative numbers.public String getPositiveSuffix()
If the affix was specified via the pattern, the string returned by this method will have
locale symbols substituted in place of special characters according to the LDML specification.
If the affix was specified via setPositiveSuffix(java.lang.String)
, the string will be returned
literally.
public void setPositiveSuffix(String suffix)
Using this method overrides the affix specified via the pattern, and unlike the pattern, the string given to this method will be interpreted literally WITHOUT locale symbol substitutions.
suffix
- The literal string to append to positive numbers.public String getNegativeSuffix()
If the affix was specified via the pattern, the string returned by this method will have
locale symbols substituted in place of special characters according to the LDML specification.
If the affix was specified via setNegativeSuffix(java.lang.String)
, the string will be returned
literally.
public void setNegativeSuffix(String suffix)
Using this method overrides the affix specified via the pattern, and unlike the pattern, the string given to this method will be interpreted literally WITHOUT locale symbol substitutions.
suffix
- The literal string to append to negative numbers.public boolean isSignAlwaysShown()
setSignAlwaysShown(boolean)
public void setSignAlwaysShown(boolean value)
More specifically, the following strategy will be used to place the plus sign:
value
- true to always show a sign; false to hide the sign on positive numbers and zero.public int getMultiplier()
setMultiplier(int)
public void setMultiplier(int multiplier)
If a percent or permille sign is specified in the pattern, the multiplier is automatically set to 100 or 1000, respectively.
If the number specified here is a power of 10, a more efficient code path will be used.
multiplier
- The number by which all numbers passed to format(double, java.lang.StringBuffer, java.text.FieldPosition)
will be multiplied.IllegalArgumentException
- If the given multiplier is zero.ArithmeticException
- when inverting multiplier produces a non-terminating decimal result
in conjunction with MathContext of unlimited precision.public BigDecimal getRoundingIncrement()
setRoundingIncrement(java.math.BigDecimal)
public void setRoundingIncrement(BigDecimal increment)
The rounding increment can be specified via the pattern string: for example, the pattern "#,##0.05" encodes a rounding increment of 0.05.
The rounding increment is applied after any multipliers might take effect; for
example, in scientific notation or when setMultiplier(int)
is used.
See setMaximumFractionDigits(int)
and setMaximumSignificantDigits(int)
for two other
ways of specifying rounding strategies.
increment
- The increment to which numbers are to be rounded.setRoundingMode(int)
,
setMaximumFractionDigits(int)
,
setMaximumSignificantDigits(int)
public void setRoundingIncrement(BigDecimal increment)
setRoundingIncrement(java.math.BigDecimal)
.increment
- The increment to which numbers are to be rounded.setRoundingIncrement(java.math.BigDecimal)
public void setRoundingIncrement(double increment)
setRoundingIncrement(java.math.BigDecimal)
.increment
- The increment to which numbers are to be rounded.setRoundingIncrement(java.math.BigDecimal)
public int getRoundingMode()
getRoundingMode
in class NumberFormat
BigDecimal.ROUND_UP
and BigDecimal.ROUND_UNNECESSARY
.setRoundingMode(int)
public void setRoundingMode(int roundingMode)
RoundingMode
used to round
numbers. The default rounding mode is HALF_EVEN, which rounds decimals to their closest whole
number, and rounds to the closest even number if at the midpoint.
For more detail on rounding modes, see the ICU User Guide.
For backwards compatibility, the rounding mode is specified as an int argument, which can be
from either the constants in BigDecimal
or the ordinal value of RoundingMode
.
The following two calls are functionally equivalent.
df.setRoundingMode(BigDecimal.ROUND_CEILING); df.setRoundingMode(RoundingMode.CEILING.ordinal());
setRoundingMode
in class NumberFormat
roundingMode
- The integer constant rounding mode to use when formatting numbers.NumberFormat.getRoundingMode()
public MathContext getMathContext()
MathContext
being used to round numbers.setMathContext(java.math.MathContext)
public void setMathContext(MathContext mathContext)
MathContext
used
to round numbers. A "math context" encodes both a rounding mode and a number of significant
digits. Most users should call setRoundingMode(int)
and/or setMaximumSignificantDigits(int)
instead of this method.
When formatting, since no division is ever performed, the default MathContext is unlimited significant digits. However, when division occurs during parsing to correct for percentages and multipliers, a MathContext of 34 digits, the IEEE 754R Decimal128 standard, is used by default. If you require more than 34 digits when parsing, you can set a custom MathContext using this method.
mathContext
- The MathContext to use when rounding numbers.ArithmeticException
- when inverting multiplier produces a non-terminating decimal result
in conjunction with MathContext of unlimited precision.MathContext
public MathContext getMathContextICU()
MathContext
being used to round numbers.setMathContext(java.math.MathContext)
public void setMathContextICU(MathContext mathContextICU)
setMathContext(java.math.MathContext)
for
MathContext
.mathContextICU
- The MathContext to use when rounding numbers.ArithmeticException
- when inverting multiplier produces a non-terminating decimal result
in conjunction with MathContext of unlimited precision.setMathContext(java.math.MathContext)
public int getMinimumIntegerDigits()
getMinimumIntegerDigits
in class NumberFormat
setMinimumIntegerDigits(int)
public void setMinimumIntegerDigits(int value)
For example, if minimum integer digits is 3, the number 12.3 will be printed as "001.23".
Minimum integer and minimum and maximum fraction digits can be specified via the pattern string. For example, "#,#00.00#" has 2 minimum integer digits, 2 minimum fraction digits, and 3 maximum fraction digits. Note that it is not possible to specify maximum integer digits in the pattern except in scientific notation.
If minimum and maximum integer, fraction, or significant digits conflict with each other, the most recently specified value is used. For example, if there is a formatter with minInt=5, and then you set maxInt=3, then minInt will be changed to 3.
setMinimumIntegerDigits
in class NumberFormat
value
- The minimum number of digits before the decimal separator.NumberFormat.getMinimumIntegerDigits()
public int getMaximumIntegerDigits()
getMaximumIntegerDigits
in class NumberFormat
setMaximumIntegerDigits(int)
public void setMaximumIntegerDigits(int value)
For example, if maximum integer digits is 3, the number 12345 will be printed as "345".
Minimum integer and minimum and maximum fraction digits can be specified via the pattern string. For example, "#,#00.00#" has 2 minimum integer digits, 2 minimum fraction digits, and 3 maximum fraction digits. Note that it is not possible to specify maximum integer digits in the pattern except in scientific notation.
If minimum and maximum integer, fraction, or significant digits conflict with each other, the most recently specified value is used. For example, if there is a formatter with minInt=5, and then you set maxInt=3, then minInt will be changed to 3.
setMaximumIntegerDigits
in class NumberFormat
value
- The maximum number of digits before the decimal separator.NumberFormat.getMaximumIntegerDigits()
public int getMinimumFractionDigits()
getMinimumFractionDigits
in class NumberFormat
setMaximumIntegerDigits(int)
public void setMinimumFractionDigits(int value)
For example, if minimum fraction digits is 2, the number 123.4 will be printed as "123.40".
Minimum integer and minimum and maximum fraction digits can be specified via the pattern string. For example, "#,#00.00#" has 2 minimum integer digits, 2 minimum fraction digits, and 3 maximum fraction digits. Note that it is not possible to specify maximum integer digits in the pattern except in scientific notation.
If minimum and maximum integer, fraction, or significant digits conflict with each other, the most recently specified value is used. For example, if there is a formatter with minInt=5, and then you set maxInt=3, then minInt will be changed to 3.
See setRoundingIncrement(java.math.BigDecimal)
and setMaximumSignificantDigits(int)
for two other
ways of specifying rounding strategies.
setMinimumFractionDigits
in class NumberFormat
value
- The minimum number of integer digits after the decimal separator.setRoundingMode(int)
,
setRoundingIncrement(java.math.BigDecimal)
,
setMaximumSignificantDigits(int)
public int getMaximumFractionDigits()
getMaximumFractionDigits
in class NumberFormat
setMaximumIntegerDigits(int)
public void setMaximumFractionDigits(int value)
For example, if maximum fraction digits is 2, the number 123.456 will be printed as "123.46".
Minimum integer and minimum and maximum fraction digits can be specified via the pattern string. For example, "#,#00.00#" has 2 minimum integer digits, 2 minimum fraction digits, and 3 maximum fraction digits. Note that it is not possible to specify maximum integer digits in the pattern except in scientific notation.
If minimum and maximum integer, fraction, or significant digits conflict with each other, the most recently specified value is used. For example, if there is a formatter with minInt=5, and then you set maxInt=3, then minInt will be changed to 3.
setMaximumFractionDigits
in class NumberFormat
value
- The maximum number of integer digits after the decimal separator.setRoundingMode(int)
public boolean areSignificantDigitsUsed()
setSignificantDigitsUsed(boolean)
public void setSignificantDigitsUsed(boolean useSignificantDigits)
Calling df.setSignificantDigitsUsed(true)
is functionally equivalent to:
df.setMinimumSignificantDigits(1); df.setMaximumSignificantDigits(6);
useSignificantDigits
- true to enable significant digit rounding; false to disable it.public int getMinimumSignificantDigits()
setMinimumSignificantDigits(int)
public void setMinimumSignificantDigits(int value)
For example, if minimum significant digits is 3 and the number is 1.2, the number will be printed as "1.20".
If minimum and maximum integer, fraction, or significant digits conflict with each other, the most recently specified value is used. For example, if there is a formatter with minInt=5, and then you set maxInt=3, then minInt will be changed to 3.
value
- The minimum number of significant digits to display.public int getMaximumSignificantDigits()
setMaximumSignificantDigits(int)
public void setMaximumSignificantDigits(int value)
For example, if maximum significant digits is 3 and the number is 12345, the number will be printed as "12300".
If minimum and maximum integer, fraction, or significant digits conflict with each other, the most recently specified value is used. For example, if there is a formatter with minInt=5, and then you set maxInt=3, then minInt will be changed to 3.
See setRoundingIncrement(java.math.BigDecimal)
and setMaximumFractionDigits(int)
for two other ways
of specifying rounding strategies.
value
- The maximum number of significant digits to display.setRoundingMode(int)
,
setRoundingIncrement(java.math.BigDecimal)
,
setMaximumFractionDigits(int)
public int getFormatWidth()
setFormatWidth(int)
public void setFormatWidth(int width)
If the number is longer than your padding width, the number will display as if no padding width had been specified, which may result in strings longer than the padding width.
Padding can be specified in the pattern string using the '*' symbol. For example, the format "*x######0" has a format width of 7 and a pad character of 'x'.
Padding is currently counted in UTF-16 code units; see ticket #13034 for more information.
width
- The minimum number of characters in the output.setPadCharacter(char)
,
setPadPosition(int)
public char getPadCharacter()
setPadCharacter(char)
public void setPadCharacter(char padChar)
setFormatWidth(int)
.
In the pattern string, the padding character is the token that follows '*' before or after the prefix or suffix.
padChar
- The character used for padding.setFormatWidth(int)
public int getPadPosition()
setPadPosition(int)
public void setPadPosition(int padPos)
setFormatWidth(int)
. For example, consider the pattern
"P123S" with padding width 8 and padding char "*". The four positions are:
PAD_BEFORE_PREFIX
⇒ "***P123S"
PAD_AFTER_PREFIX
⇒ "P***123S"
PAD_BEFORE_SUFFIX
⇒ "P123***S"
PAD_AFTER_SUFFIX
⇒ "P123S***"
padPos
- The position used for padding.setFormatWidth(int)
public boolean isScientificNotation()
setScientificNotation(boolean)
public void setScientificNotation(boolean useScientific)
Calling df.setScientificNotation(true)
is functionally equivalent to calling
df.setMinimumExponentDigits(1)
.
useScientific
- true to enable scientific notation; false to disable it.setMinimumExponentDigits(byte)
public byte getMinimumExponentDigits()
setMinimumExponentDigits(byte)
public void setMinimumExponentDigits(byte minExpDig)
This setting corresponds to the number of zeros after the 'E' in a pattern string such as "0.00E000".
minExpDig
- The minimum number of digits in the exponent.public boolean isExponentSignAlwaysShown()
setExponentSignAlwaysShown(boolean)
public void setExponentSignAlwaysShown(boolean expSignAlways)
This setting corresponds to the '+' in a pattern such as "0.00E+0".
expSignAlways
- true to always shown the sign in the exponent; false to show it for
negatives but not positives.public boolean isGroupingUsed()
isGroupingUsed
in class NumberFormat
setGroupingUsed(boolean)
public void setGroupingUsed(boolean enabled)
For example, if grouping is enabled, 12345 will be printed as "12,345" in en-US. If grouping were disabled, it would instead be printed as simply "12345".
setGroupingUsed
in class NumberFormat
enabled
- true to enable grouping separators; false to disable them.setGroupingSize(int)
,
setSecondaryGroupingSize(int)
public int getGroupingSize()
setGroupingSize(int)
public void setGroupingSize(int width)
For example, with a grouping size of 3, the number 1234567 will be formatted as "1,234,567".
Grouping size can also be specified in the pattern: for example, "#,##0" corresponds to a grouping size of 3.
width
- The grouping size to use.setSecondaryGroupingSize(int)
public int getSecondaryGroupingSize()
setSecondaryGroupingSize(int)
public void setSecondaryGroupingSize(int width)
For example, with primary grouping size 3 and secondary grouping size 2, the number 1234567 will be formatted as "12,34,567".
Grouping size can also be specified in the pattern: for example, "#,##,##0" corresponds to a primary grouping size of 3 and a secondary grouping size of 2.
width
- The secondary grouping size to use.setGroupingSize(int)
public int getMinimumGroupingDigits()
setMinimumGroupingDigits(int)
public void setMinimumGroupingDigits(int number)
number
- The minimum number of digits before grouping is triggered.public boolean isDecimalSeparatorAlwaysShown()
setDecimalSeparatorAlwaysShown(boolean)
public void setDecimalSeparatorAlwaysShown(boolean value)
This setting can be specified in the pattern for integer formats: "#,##0." is an example.
value
- true to always show the decimal separator; false to show it only when there is a
fraction part of the number.public Currency getCurrency()
getCurrency
in class NumberFormat
setCurrency(com.ibm.icu.util.Currency)
,
DecimalFormatSymbols.getCurrency()
public void setCurrency(Currency currency)
setCurrencyUsage(com.ibm.icu.util.Currency.CurrencyUsage)
)
NumberFormat.getCurrencyInstance()
or one of its friends.setCurrency
in class NumberFormat
currency
- The currency to use.public Currency.CurrencyUsage getCurrencyUsage()
setCurrencyUsage(com.ibm.icu.util.Currency.CurrencyUsage)
public void setCurrencyUsage(Currency.CurrencyUsage usage)
setMinimumFractionDigits(int)
and setMaximumFractionDigits(int)
or
setRoundingIncrement(java.math.BigDecimal)
.usage
- The strategy to use when rounding in the current currency.public CurrencyPluralInfo getCurrencyPluralInfo()
setCurrencyPluralInfo(com.ibm.icu.text.CurrencyPluralInfo)
public void setCurrencyPluralInfo(CurrencyPluralInfo newInfo)
Most users should not call this method directly. You should instead create
your formatter via NumberFormat.getInstance(NumberFormat.PLURALCURRENCYSTYLE)
.
newInfo
- The CurrencyPluralInfo to use when printing currency long names.public boolean isParseBigDecimal()
parse(java.lang.String, java.text.ParsePosition)
will always return a BigDecimal.setParseBigDecimal(boolean)
public void setParseBigDecimal(boolean value)
parse(java.lang.String, java.text.ParsePosition)
prefer returning a BigDecimal
when
possible. For strings corresponding to return values of Infinity, -Infinity, NaN, and -0.0, a
Double will be returned even if ParseBigDecimal is enabled.value
- true to cause parse(java.lang.String, java.text.ParsePosition)
to prefer BigDecimal; false to let parse(java.lang.String, java.text.ParsePosition)
return additional data types like Long or BigInteger.@Deprecated public int getParseMaxDigits()
@Deprecated public void setParseMaxDigits(int maxDigits)
maxDigits
- Prior to ICU 59, the maximum number of digits in the output number after
exponential notation is applied.public boolean isParseStrict()
isParseStrict
in class NumberFormat
NumberFormat.setParseStrict(boolean)
public void setParseStrict(boolean parseStrict)
setParseStrict
in class NumberFormat
parseStrict
- True to enable strict parsing. Default is false.NumberFormat.isParseStrict()
@Deprecated public void setParseStrictMode(com.ibm.icu.impl.number.DecimalFormatProperties.ParseMode parseMode)
DecimalFormatProperties.ParseMode.JAVA_COMPATIBILITY
.public boolean isParseIntegerOnly()
isParseIntegerOnly
in class NumberFormat
setParseIntegerOnly(boolean)
public void setParseIntegerOnly(boolean parseIntegerOnly)
For example, in en-US, parsing the string "123.45" will return the number 123 and parse position 3.
This is functionally equivalent to calling setDecimalPatternMatchRequired(boolean)
and a
pattern without a decimal point.
setParseIntegerOnly
in class NumberFormat
parseIntegerOnly
- true to ignore fractional parts of numbers when parsing; false to
consume fractional parts.NumberFormat.isParseIntegerOnly()
public boolean isDecimalPatternMatchRequired()
setDecimalPatternMatchRequired(boolean)
public void setDecimalPatternMatchRequired(boolean value)
To require a decimal point, call this method in combination with either a pattern
containing a decimal point or with setDecimalSeparatorAlwaysShown(boolean)
.
// Require a decimal point in the string being parsed: df.applyPattern("#."); df.setDecimalPatternMatchRequired(true); // Alternatively: df.setDecimalSeparatorAlwaysShown(true); df.setDecimalPatternMatchRequired(true);To forbid a decimal point, call this method in combination with a pattern containing no decimal point. Alternatively, use
setParseIntegerOnly(boolean)
for the same behavior without
depending on the contents of the pattern string.
// Forbid a decimal point in the string being parsed: df.applyPattern("#"); df.setDecimalPatternMatchRequired(true);
value
- true to either require or forbid the decimal point according to the pattern; false
to disable this feature.setParseIntegerOnly(boolean)
public boolean isParseNoExponent()
setParseNoExponent(boolean)
public void setParseNoExponent(boolean value)
value
- true to prevent exponents from being parsed; false to allow them to be parsed.public boolean isParseCaseSensitive()
setParseNoExponent(boolean)
public void setParseCaseSensitive(boolean value)
UCharacter.foldCase(int, boolean)
.value
- true to force case (uppercase/lowercase) to match when parsing; false to ignore
case and perform case folding.public boolean equals(Object obj)
If two DecimalFormat instances are equal, then they will always produce the same output. However, the reverse is not necessarily true: if two DecimalFormat instances always produce the same output, they are not necessarily equal.
equals
in class NumberFormat
obj
- the object to compare againstpublic int hashCode()
hashCode
in class NumberFormat
public String toString()
public String toPattern()
For more information on decimal format pattern strings, see UTS #35.
Important: Not all properties are capable of being encoded in a pattern
string. See a list of properties in applyPattern(java.lang.String)
.
public String toLocalizedPattern()
toPattern()
and converts the string to localized notation. For more information on
localized notation, see applyLocalizedPattern(java.lang.String)
. This method is provided for backwards
compatibility and should not be used in new projects.public LocalizedNumberFormatter toNumberFormatter()
LocalizedNumberFormatter
with the same behavior as this instance of
DecimalFormat.NumberFormatter
@Deprecated public PluralRules.IFixedDecimal getFixedDecimal(double number)
@Deprecated public void setProperties(DecimalFormat.PropertySetter func)
Copyright © 2016 Unicode, Inc. and others.