DecimalFormat is a concrete subclass of
NumberFormat that formats decimal numbers in a localized manner.
It has a variety of features designed to make it possible to parse and format
numbers in any locale, including support for Western, Arabic, and Indic digits.
It also supports different kinds of numbers, including integers (123), fixed-point
numbers (123.4), scientific notation (1.23E4), percentages (12%), and
currency amounts ($123).
NumberFormat
factory methods, such as NumberFormat#getInstance().
These factory methods may not always return a DecimalFormat
depending on the locale-service provider implementation
installed. Thus, to use an instance method defined by DecimalFormat,
the NumberFormat returned by the factory method should be
type checked before converted to DecimalFormat. If the installed locale-sensitive
service implementation does not support the given Locale, the parent
locale chain will be looked up, and a Locale used that is supported.
If the factory methods are not desired, use one of the constructors such
as DecimalFormat(String pattern). See the Pattern section for more information on the pattern parameter.
NumberFormat nFmt = NumberFormat.getCurrencyInstance(Locale.US); if (nFmt instanceof DecimalFormat dFmt) { // pattern match to DecimalFormat to use setPositiveSuffix(String) dFmt.setPositiveSuffix(" dollars"); dFmt.format(100000); // returns "$100,000.00 dollars" dFmt.parse("$100,000.00 dollars"); // returns 100000 }
DecimalFormat can adjust its rounding using setRoundingMode(RoundingMode). By default, it uses
RoundingMode.HALF_EVEN .
DecimalFormat uses the ten consecutive
characters starting with the localized zero digit defined in the
DecimalFormatSymbols object as digits.
When parsing, these digits as well as all Unicode decimal digits, as
defined by Character., are recognized.
pattern or using one of the appropriate DecimalFormat setter methods,
for example, setMinimumFractionDigits(int). These limits have no impact
on parsing behavior.
Not a Number (NaN) is formatted as a string,
which is typically given as "NaN". This string is determined by DecimalFormatSymbols#getNaN(). This is the only value for which the prefixes
and suffixes are not attached.
Infinity is formatted as a string, which is typically given as
"∞" (U+221E), with the positive or negative prefixes and suffixes
attached. This string is determined by DecimalFormatSymbols#getInfinity().
Negative zero ("-0") parses to
BigDecimal(0) if isParseBigDecimal() is
true
Long(0) if isParseBigDecimal() is false
and isParseIntegerOnly() is true
Double(-0.0) if both isParseBigDecimal()
and isParseIntegerOnly() are false
Decimal formats are generally not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.
DecimalFormat comprises a pattern and a set of
symbols. The pattern may be set directly using applyPattern(),
or indirectly using the various API methods. The symbols are stored in a DecimalFormatSymbols object. When using the NumberFormat factory
methods, the pattern and symbols are created from the locale-sensitive service
implementation installed.
DecimalFormat patterns have the following syntax:
Pattern:
PositivePattern
PositivePattern ; NegativePattern
PositivePattern:
Prefixopt Number Suffixopt
NegativePattern:
Prefixopt Number Suffixopt
Prefix:
Any characters except the special pattern characters
Suffix:
Any characters except the special pattern characters
Number:
Integer Exponentopt
Integer . Fraction Exponentopt
Integer:
MinimumInteger
#
# Integer
# , Integer
MinimumInteger:
0
0 MinimumInteger
0 , MinimumInteger
Fraction:
MinimumFractionopt OptionalFractionopt
MinimumFraction:
0 MinimumFractionopt
OptionalFraction:
# OptionalFractionopt
Exponent:
E MinimumExponent
MinimumExponent:
0 MinimumExponentopt
The special characters in the table below are interpreted syntactically when used in the DecimalFormat pattern. They must be quoted, unless noted otherwise, if they are to appear in the prefix or suffix as literals.
The characters in the Symbol column are used in non-localized
patterns. The corresponding characters in the Localized Symbol column are used
in localized patterns, with the characters in Symbol losing their
syntactical meaning. Two exceptions are the currency sign (U+00A4) and
quote (U+0027), which are not localized.
Non-localized patterns should be used when calling applyPattern(String).
Localized patterns should be used when calling applyLocalizedPattern(String).
Symbol Localized Symbol Location Meaning 0DecimalFormatSymbols#getZeroDigit()Number Digit #DecimalFormatSymbols#getDigit()Number Digit, zero shows as absent .DecimalFormatSymbols#getDecimalSeparator()Number Decimal separator or monetary decimal separator - (U+002D)DecimalFormatSymbols#getMinusSign()Number Minus sign ,DecimalFormatSymbols#getGroupingSeparator()Number Grouping separator or monetary grouping separator EDecimalFormatSymbols#getExponentSeparator()Number Separates mantissa and exponent in scientific notation. This value is case sensistive. Need not be quoted in prefix or suffix. ;DecimalFormatSymbols#getPatternSeparator()Subpattern boundary Separates positive and negative subpatterns %DecimalFormatSymbols#getPercent()Prefix or suffix Multiply by 100 and show as percentage ‰ ( U+2030)DecimalFormatSymbols#getPerMill()Prefix or suffix Multiply by 1000 and show as per mille value ¤ ( U+00A4)n/a (not localized) Prefix or suffix Currency sign, replaced by currency symbol. If doubled, replaced by international currency symbol. If present in a pattern, the monetary decimal/grouping separators are used instead of the decimal/grouping separators. ' (U+0027)n/a (not localized) Prefix or suffix Used to quote special characters in a prefix or suffix, for example, "'#'#"formats 123 to"#123". To create a single quote itself, use two in a row:"# o''clock".
DecimalFormat pattern, if the pattern is not
in scientific notation, the maximum number of integer digits will not be
derived from the pattern, and instead set to Integer#MAX_VALUE.
Otherwise, if the pattern is in scientific notation, the maximum number of
integer digits will be derived from the pattern. This derivation is detailed
in the Scientific Notation section. setMaximumIntegerDigits(int) can be used to manually adjust the maximum
integer digits.
DecimalFormat pattern contains a positive and negative
subpattern, for example, "#,##0.00;(#,##0.00)". Each
subpattern has a prefix, numeric part, and suffix. The negative subpattern
is optional; if absent, then the positive subpattern prefixed with the
minus sign '-' (U+002D HYPHEN-MINUS) is used as the
negative subpattern. That is, "0.00" alone is equivalent to
"0.00;-0.00". If there is an explicit negative subpattern, it
serves only to specify the negative prefix and suffix; the number of digits,
minimal digits, and other characteristics are all the same as the positive
pattern. That means that "#,##0.0#;(#)" produces precisely
the same behavior as "#,##0.0#;(#,##0.0#)". In
lenient parsing mode, loose matching of the
minus sign pattern is enabled, following the LDML’s
loose matching specification.
The prefixes, suffixes, and various symbols used for infinity, digits,
grouping separators, decimal separators, etc. may be set to arbitrary
values, and they will appear properly during formatting. However, care must
be taken that the symbols and strings do not conflict, or parsing will be
unreliable. For example, either the positive and negative prefixes or the
suffixes must be distinct for DecimalFormat.parse() to be able
to distinguish positive from negative values. (If they are identical, then
DecimalFormat will behave as if no negative subpattern was
specified.) Another example is that the decimal separator and grouping
separator should be distinct characters, or parsing will be impossible.
The grouping separator is commonly used for thousands, but in some
locales it separates ten-thousands. The grouping size is a constant number
of digits between the grouping characters, such as 3 for 100,000,000 or 4 for
1,0000,0000. If you supply a pattern with multiple grouping characters, the
interval between the last one and the end of the integer is the one that is
used. For example, "#,##,###,####" == "######,####" ==
"##,####,####".
Numbers in scientific notation are expressed as the product of a mantissa
and a power of ten, for example, 1234 can be expressed as 1.234 x 10^3. The
mantissa is often in the range 1.0 ≤ x < 10.0, but it need not
be.
DecimalFormat can be instructed to format and parse scientific
notation only via a pattern; there is currently no factory method
that creates a scientific notation format. In a pattern, the exponent
character immediately followed by one or more digit characters indicates
scientific notation. Example: "0.###E0" formats the number
1234 as "1.234E3".
"0.###E0 m/s".
"#00.0####E0" would have a minimum number of
integer digits = 2("00") and a maximum number of integer digits = 3("#00"). It
would have a minimum number of fraction digits = 1("0") and a maximum number of fraction
digits= 5("0####").
"##0.#####E0". Using this pattern, the number 12345
formats to "12.345E3", and 123456 formats to
"123.456E3".
"00.###E0" yields
"12.3E-4".
Mantissa Digits:
min(max(Minimum Pattern Digits, Original Number Digits), Maximum Pattern Digits)
Minimum pattern Digits:
Minimum Integer Digits + Minimum Fraction Digits
Maximum pattern Digits:
Maximum Integer Digits + Maximum Fraction Digits
Original Number Digits:
The amount of significant digits in the number to be formatted
This means that generally, a mantissa will have up to the combined maximum integer
and fraction digits, if the original number itself has enough significant digits. However,
if there are more minimum pattern digits than significant digits in the original number,
the mantissa will have significant digits that equals the combined
minimum integer and fraction digits. The number of significant digits
does not affect parsing.
It should be noted, that the integer portion of the mantissa will give any excess digits to the fraction portion, whether it be for precision or for satisfying the total amount of combined minimum digits.
This behavior can be observed in the following example,
DecimalFormat df = new DecimalFormat("#000.000##E0"); df.format(12); // returns "12.0000E0" df.format(123456789) // returns "1.23456789E8"
Implementation Specification
When formatting a Number other than BigInteger and
BigDecimal, 309 is used as the upper limit for integer digits,
and 340 as the upper limit for fraction digits. This occurs, even if
one of the DecimalFormat getter methods, for example, getMinimumFractionDigits()
returns a numerically greater value.
NumberFormat, DecimalFormatSymbols, ParsePosition, Locale
| Modifier and Type | Class and Description |
|---|---|
| private static class | DecimalFormat.
The digit arrays used in the fast-path methods for collecting digits. |
| private static class | DecimalFormat.
Helper inner utility class for storing the data used in the fast-path algorithm. |
| pack-priv static record | DecimalFormat.
NumericPosition is a helper record class that stores two indices of interest. |
| Modifier and Type | Field and Description |
|---|---|
| private transient BigDecimal | |
| private transient BigInteger | |
| private static final char | CURRENCY_SIGN
The CURRENCY_SIGN is the standard Unicode symbol for currency. |
| pack-priv static final int | |
| private boolean | decimalSeparatorAlwaysShown
If true, forces the decimal separator to always appear in a formatted number, even if the fractional part of the number is zero. |
| private transient DigitList | |
| pack-priv static final int | |
| pack-priv static final int | |
| private static FieldPosition[] | |
| private transient boolean | fastPathCheckNeeded
Flag stating need of check and reinit fast-path status on next format call. |
| private transient DecimalFormat. | fastPathData
DecimalFormat reference to its FastPathData |
| private byte | groupingSize
The number of digits between grouping separators in the integer portion of a number. |
| private transient boolean | isCurrencyFormat
True if this object represents a currency format. |
| private transient boolean | isFastPath
The format fast-path status of the instance. |
| private static final double | MAX_INT_AS_DOUBLE
Maximum valid integer value for applying fast-path algorithm |
| pack-priv static final int | |
| pack-priv static final int | |
| private int | maximumFractionDigits
Hides java. BigInteger or BigDecimal number.
|
| private int | maximumIntegerDigits
Hides java. BigInteger or BigDecimal number.
|
| private byte | minExponentDigits
The minimum number of digits used to display the exponent when a number is formatted in exponential notation. |
| private int | minimumFractionDigits
Hides java. BigInteger or BigDecimal number.
|
| private int | minimumIntegerDigits
Hides java. BigInteger or BigDecimal number.
|
| private int | multiplier
The multiplier for use in percent, per mille, etc. |
| private String | negativePrefix
The symbol used as a prefix when formatting negative numbers, e.g. "-". |
| private transient FieldPosition[] | negativePrefixFieldPositions
FieldPositions describing the negative prefix String. |
| private String | negativeSuffix
The symbol used as a suffix when formatting negative numbers. |
| private transient FieldPosition[] | negativeSuffixFieldPositions
FieldPositions describing the negative suffix String. |
| private String | negPrefixPattern
The prefix pattern for negative numbers. |
| private String | negSuffixPattern
The suffix pattern for negative numbers. |
| private boolean | parseBigDecimal
If true, parse returns BigDecimal wherever possible. |
| private boolean | parseStrict
True if this |
| private static final char | |
| private static final char | |
| private static final String | |
| private static final char | |
| private static final char | |
| private static final char | |
| private static final char | |
| private static final char | |
| private static final char | |
| private String | positivePrefix
The symbol used as a prefix when formatting positive numbers, e.g. "+". |
| private transient FieldPosition[] | positivePrefixFieldPositions
FieldPositions describing the positive prefix String. |
| private String | positiveSuffix
The symbol used as a suffix when formatting positive numbers. |
| private transient FieldPosition[] | positiveSuffixFieldPositions
FieldPositions describing the positive suffix String. |
| private String | posPrefixPattern
The prefix pattern for non-negative numbers. |
| private String | posSuffixPattern
The suffix pattern for non-negative numbers. |
| private static final char | |
| private RoundingMode | roundingMode
The |
| private int | serialVersionOnStream
The internal serial version which says which version was written.
|
| pack-priv static final long | |
| private static final int | |
| private static final int | |
| private static final int | |
| private DecimalFormatSymbols | symbols
The |
| private boolean | useExponentialNotation
True to force the use of exponential (i.e. scientific) notation when formatting numbers. |
| Access | Constructor and Description |
|---|---|
| public | DecimalFormat()
Creates a DecimalFormat using the default pattern and symbols
for the default |
| public | DecimalFormat(String
a non-localized pattern string. pattern)Creates a DecimalFormat using the given pattern and the symbols
for the default |
| public | DecimalFormat(String
a non-localized pattern string pattern, DecimalFormatSymbols the set of symbols to be used symbols)Creates a DecimalFormat using the given pattern and symbols. |
| Modifier and Type | Method and Description |
|---|---|
| private void | addAffixes(char[]
Char array container which to prepend/append the
prefix/suffix. container, char[] Char sequence to prepend as a prefix. prefix, char[] Char sequence to append as a suffix. suffix)Internal utility. |
| private void | append(Format.
Appends the String |
| private void | appendAffix(StringBuilder
the affix string is appended to this buffer, String a pattern such as posPrefixPattern; may be null affixPattern, String a corresponding expanded affix, such as positivePrefix.
Ignored unless affixPattern is null. If affixPattern is null, then
expAffix is appended as a literal affix. expAffix, boolean true if the appended pattern should contain localized
pattern characters; otherwise, non-localized pattern chars are appended localized)Appends an affix pattern to the given StringBuilder, quoting special characters as needed. |
| private void | appendAffix(StringBuilder buffer, String affix, boolean localized)
Append an affix to the given StringBuilder, using quotes if there are special characters. |
| private void | appendSuffix(char[]
The suffix characters to append to result. suffix, int The number of chars to append. len, char[] Char array container which to append the suffix container)Appends the passed |
| public void | |
| public void | |
| private void | |
| private boolean | |
| public Object | |
| private void | collectFractionalDigits(int
The int value from which we collect digits. number, char[] The char array container where digits are stored. digitsBuffer, int the position from which we start storing digits in
digitsBuffer. startIndex)Collects the 2 (currency) or 3 (decimal) fractional digits from passed
|
| private void | collectIntegralDigits(int
The int value from which we collect digits. number, char[] The char array container where digits and grouping chars
are stored. digitsBuffer, int the position from which we start storing digits in
digitsBuffer. backwardIndex)Collects integral digits from passed |
| pack-priv Format. | doubleSubformat(double number, Format.
|
| public boolean | Returns: true if the specified object is equal to this DecimalFormatobject to be compared for equality obj)Overrides java. Compares the specified object with this |
| private boolean | Returns: the decision that must be taken regarding half-even rounding.The fractional value on which we take rounding
decision. fractionalPart, int The integral part of the scaled
fractional value. scaledFractionalPartAsInt)Returns true if rounding-up must be done on |
| private String | Returns: the expanded equivalent of patternthe non-null, possibly empty pattern pattern, StringBuilder a scratch StringBuilder; its contents will be lost buffer)Expand an affix pattern into an affix string. |
| private FieldPosition[] | Returns: FieldPosition array of the resulting fields.the non-null, possibly empty pattern pattern)Expand an affix pattern into an array of FieldPositions describing how the pattern would be expanded. |
| private void | |
| private void | fastDoubleFormat(double
the double value to be formatted. d, boolean Flag precising if negative)d is negative.This is the main entry point for the fast-path format algorithm. |
| pack-priv String | Returns: the formatted result ford as a string.The double value to be formatted d)Overrides java. A fast-path shortcut of format(double) to be called by NumberFormat, or by format(double, ...) public methods. |
| public final StringBuffer | Returns: the value passed in astoAppendTothe number to format number, StringBuffer the toAppendTo, FieldPosition StringBuffer to which the formatted
text is to be appendedkeeps track on the position of the field within the
returned string. For example, for formatting a number
pos)1234567.89 in Locale.US locale,
if the given fieldPosition is
NumberFormat#INTEGER_FIELD, the begin index
and end index of fieldPosition will be set
to 0 and 9, respectively for the output string
1,234,567.89.Overrides java. Formats a number and appends the resulting text to the given string buffer. |
| pack-priv final Format. | format(Object number, Format.
Overrides java.
|
| public StringBuffer | Returns: The formatted number stringThe double to format number, StringBuffer where the text is to be appended result, FieldPosition keeps track on the position of the field within
the returned string. For example, for formatting
a number fieldPosition)1234567.89 in Locale.US
locale, if the given fieldPosition is
NumberFormat#INTEGER_FIELD, the begin index
and end index of fieldPosition will be set
to 0 and 9, respectively for the output string
1,234,567.89.Implements abstract java. Formats a double to produce a string. |
| pack-priv Format. | format(double number, Format.
Overrides java.
|
| pack-priv Format. | Returns: The formatted number stringThe double to format number, Format.where the text is to be appended result,notified of locations of sub fields delegateFormats a double to produce a string. |
| public StringBuffer | Returns: The formatted number stringThe long to format number, StringBuffer where the text is to be appended result, FieldPosition keeps track on the position of the field within
the returned string. For example, for formatting
a number fieldPosition)123456789 in Locale.US
locale, if the given fieldPosition is
NumberFormat#INTEGER_FIELD, the begin index
and end index of fieldPosition will be set
to 0 and 11, respectively for the output string
123,456,789.Implements abstract java. Format a long to produce a string. |
| pack-priv Format. | format(long number, Format.
Overrides java.
|
| pack-priv Format. | Returns: The formatted number stringThe long to format number, Format.where the text is to be appended result,notified of locations of sub fields delegateFormat a long to produce a string. |
| private Format. | Returns: The formatted number stringThe BigDecimal to format number, Format.where the text is to be appended result,keeps track on the position of the field within
the returned string. For example, for formatting
a number fieldPosition)1234567.89 in Locale.US
locale, if the given fieldPosition is
NumberFormat#INTEGER_FIELD, the begin index
and end index of fieldPosition will be set
to 0 and 9, respectively for the output string
1,234,567.89.Formats a BigDecimal to produce a string. |
| pack-priv Format. | Returns: The formatted number stringThe BigDecimal to format number, Format.where the text is to be appended result,notified of locations of sub fields delegateFormats a BigDecimal to produce a string. |
| private Format. | Returns: The formatted number stringThe BigInteger to format number, Format.where the text is to be appended result,keeps track on the position of the field within
the returned string. For example, for formatting
a number fieldPosition)123456789 in Locale.US
locale, if the given fieldPosition is
NumberFormat#INTEGER_FIELD, the begin index
and end index of fieldPosition will be set
to 0 and 11, respectively for the output string
123,456,789.Format a BigInteger to produce a string. |
| pack-priv Format. | Returns: The formatted number stringThe BigInteger to format number, Format.where the text is to be appended result,notified of locations of sub fields delegate,Format a BigInteger to produce a string. |
| public AttributedCharacterIterator | Returns: AttributedCharacterIterator describing the formatted value.The object to format obj)Overrides java. Formats an Object producing an |
| private BigDecimal | |
| private BigInteger | |
| public Currency | Returns: the currency used by this decimal format, ornullOverrides java. Gets the currency used by this decimal format when formatting currency values. |
| public DecimalFormatSymbols | Returns: a copy of the desired DecimalFormatSymbolsReturns a copy of the decimal format symbols, which is generally not changed by the programmer or user. |
| pack-priv DigitList | Returns: theDigitList used by this DecimalFormat instanceReturns the |
| public int | |
| public int | getMaximumFractionDigits()
Overrides java. Returns the maximum number of digits allowed in the fraction portion of a number during formatting. |
| public int | getMaximumIntegerDigits()
Overrides java. Returns the maximum number of digits allowed in the integer portion of a number during formatting. |
| public int | getMinimumFractionDigits()
Overrides java. Returns the minimum number of digits allowed in the fraction portion of a number during formatting. |
| public int | getMinimumIntegerDigits()
Overrides java. Returns the minimum number of digits allowed in the integer portion of a number during formatting. |
| public int | Returns: the multiplierGets the multiplier for use in percent, per mille, and similar formats. |
| public String | |
| private FieldPosition[] | Returns: FieldPositions in positive prefixReturns the FieldPositions of the fields in the prefix used for negative numbers. |
| public String | |
| private FieldPosition[] | Returns: FieldPositions in positive prefixReturns the FieldPositions of the fields in the suffix used for negative numbers. |
| public String | |
| private FieldPosition[] | Returns: FieldPositions in positive prefixReturns the FieldPositions of the fields in the prefix used for positive numbers. |
| public String | |
| private FieldPosition[] | Returns: FieldPositions in positive prefixReturns the FieldPositions of the fields in the suffix used for positive numbers. |
| public RoundingMode | Returns: TheRoundingMode used for this DecimalFormat.Overrides java. Gets the |
| private int | |
| pack-priv boolean | Returns: true, if number is aDouble.NEGATIVE_INFINITY or
Double.POSITIVE_INFINITY; false otherwisethe double number to format number, Format.where the text is to be appended result,notified of locations of sub fields delegate,whether the given isNegative)number is negativeChecks if the given |
| pack-priv boolean | Returns: true, if number is a NaN; false otherwisethe double number to format number, Format.where the text is to be appended result,notified of locations of sub fields delegateChecks if the given |
| public int | Returns: the hash code for thisDecimalFormatOverrides java. Returns the hash code for this |
| public boolean | Returns: true if the decimal separator is always shown;
false otherwiseAllows you to get the behavior of the decimal separator with integers. |
| private boolean | |
| public boolean | Returns: true if the parse method returns BigDecimal;
false otherwiseReturns whether the |
| public boolean | isStrict()
Overrides java. Returns |
| private void | localizeDigits(char[]
The char array container where the digits are stored. digitsBuffer)Converts digit chars from |
| pack-priv boolean | Returns: true if the text matches the affixReturns true if the text matches the affix. |
| public Number | Returns: the parsed value, ornull if the parse failsthe string to be parsed text, ParsePosition A pos)ParsePosition object with index and error
index information as described above.Implements abstract java. Parses text from the beginning of the given string to produce a |
| private boolean | posEqualsNegPattern()
This method returns true if the positive and negative prefix/suffix values are equivalent. |
| private void | prependPrefix(char[]
The prefix characters to prepend to result. prefix, int The number of chars to prepend. len, char[] Char array container which to prepend the prefix container)Prepends the passed |
| private void | readObject(ObjectInputStream stream)
Hides java. Reads the default serializable fields from the stream and performs validations and adjustments for older serialized versions. |
| private void | |
| public void | setCurrency(Currency
the new currency to be used by this decimal format currency)Overrides java. Sets the currency used by this number format when formatting currency values. |
| public void | setDecimalFormatSymbols(DecimalFormatSymbols
desired DecimalFormatSymbols newSymbols)Sets the decimal format symbols, which is generally not changed by the programmer or user. |
| public void | setDecimalSeparatorAlwaysShown(boolean
true if the decimal separator is always shown;
false otherwiseAllows you to set the behavior of the decimal separator with integers. |
| pack-priv void | setDigitList(Number
the number to format number, boolean true, if the number is negative; false otherwise isNegative, int the max digits maxDigits)Utility method that sets the |
| public void | |
| public void | setGroupingUsed(boolean newValue)
Overrides java. Set whether or not grouping will be used in this format. |
| public void | setMaximumFractionDigits(int
the maximum number of fraction digits to be shown. newValue)Overrides java. Sets the maximum number of digits allowed in the fraction portion of a number during formatting. |
| public void | setMaximumIntegerDigits(int
the maximum number of integer digits to be shown. newValue)Overrides java. Sets the maximum number of digits allowed in the integer portion of a number during formatting. |
| public void | setMinimumFractionDigits(int
the minimum number of fraction digits to be shown. newValue)Overrides java. Sets the minimum number of digits allowed in the fraction portion of a number during formatting. |
| public void | setMinimumIntegerDigits(int
the minimum number of integer digits to be shown. newValue)Overrides java. Sets the minimum number of digits allowed in the integer portion of a number during formatting. |
| public void | setMultiplier(int
the new multiplier newValue)Sets the multiplier for use in percent, per mille, and similar formats. |
| public void | |
| public void | |
| public void | setParseBigDecimal(boolean
true if the parse method returns BigDecimal;
false otherwiseSets whether the |
| public void | |
| public void | |
| public void | setRoundingMode(RoundingMode
The roundingMode)RoundingMode to be usedOverrides java. Sets the |
| public void | setStrict(boolean strict)
Overrides java. Change the leniency value for parsing. |
| private int | |
| private Format. | subformat(Format.
Complete the formatting of a finite number. |
| pack-priv void | subformatNumber(Format.
where the text is to be appended result,notified of the location of sub fields delegate,true, if the number is negative; false otherwise isNegative, boolean true, if the number is an integer; false otherwise isInteger, int maximum integer digits maxIntDigits, int minimum integer digits minIntDigits, int maximum fraction digits maxFraDigits, int minimum fraction digits minFraDigits)Subformats number part using the |
| private final boolean | subparse(String
The string to parse. text, ParsePosition The position at which to being parsing. Upon
return, the first unparseable character. parsePosition, String positivePrefix, String negativePrefix, DigitList The DigitList to set to the parsed value. digits, boolean If true, parse an exponent. This means no
infinite values and integer only. isExponent, boolean[] Upon return contains boolean status flags indicating
whether the value was infinite and whether it was positive. status)Parse the given text into a number. |
| pack-priv DecimalFormat. | Returns: returns aNumericPosition that stores both a full
traversal index, and an int only index.the string to parse text, int the position at which parsing begins position, DigitList the DigitList to set to the parsed value digits, boolean whether to check for exponential number checkExponent, boolean if the exponential part is encountered isExponent, boolean[] upon return contains boolean status flags indicating
whether the value is infinite and whether it is
positive status)Parses a number from the given |
| public String | Returns: a localized pattern stringSynthesizes a localized pattern string that represents the current state of this Format object. |
| public String | Returns: a pattern stringSynthesizes a pattern string that represents the current state of this Format object. |
| private String | |
| public String | Returns: a string identifying thisDecimalFormat, for debuggingOverrides java. Returns a string identifying this |