public static final class DoubleFormat.Builder extends Object
Modifier and Type | Method and Description |
---|---|
DoubleFormat.Builder |
allowSignedZero(boolean signedZero)
Sets the flag determining whether or not the zero string may be returned with the minus
sign or if it will always be returned in the positive form.
|
DoubleFormat.Builder |
alwaysIncludeExponent(boolean alwaysIncludeExponent)
Sets the flag indicating if an exponent value should always be included in the
formatted value, even if the exponent value is zero.
|
DoubleFunction<String> |
build()
Builds a new double format function.
|
DoubleFormat.Builder |
decimalSeparator(char decimalSeparator)
Sets the decimal separator character, i.e., the character placed between the
whole number and fractional portions of the formatted strings.
|
DoubleFormat.Builder |
digits(String digits)
Sets the string containing the digit characters 0-9, in that order.
|
DoubleFormat.Builder |
exponentSeparator(String exponentSeparator)
Sets the exponent separator character, i.e., the string placed between
the mantissa and the exponent.
|
DoubleFormat.Builder |
formatSymbols(DecimalFormatSymbols symbols)
Configures this instance with the given format symbols.
|
DoubleFormat.Builder |
groupingSeparator(char groupingSeparator)
Sets the character used to separate groups of thousands.
|
DoubleFormat.Builder |
groupThousands(boolean groupThousands)
If set to
true , thousands will be grouped with the
grouping separator . |
DoubleFormat.Builder |
includeFractionPlaceholder(boolean fractionPlaceholder)
Sets the flag determining whether or not a zero character is added in the fraction position
when no fractional value is present.
|
DoubleFormat.Builder |
infinity(String infinity)
Sets the string used to represent infinity.
|
DoubleFormat.Builder |
maxPrecision(int maxPrecision)
Sets the maximum number of significant decimal digits used in format
results.
|
DoubleFormat.Builder |
minDecimalExponent(int minDecimalExponent)
Sets the minimum decimal exponent for formatted strings.
|
DoubleFormat.Builder |
minusSign(char minusSign)
Sets the character used as the minus sign.
|
DoubleFormat.Builder |
nan(String nan)
Sets the string used to represent
Double.NaN . |
DoubleFormat.Builder |
plainFormatMaxDecimalExponent(int plainFormatMaxDecimalExponent)
Sets the maximum decimal exponent for numbers formatted as plain decimal strings when
using the
MIXED format type. |
DoubleFormat.Builder |
plainFormatMinDecimalExponent(int plainFormatMinDecimalExponent)
Sets the minimum decimal exponent for numbers formatted as plain decimal strings when
using the
MIXED format type. |
public DoubleFormat.Builder allowSignedZero(boolean signedZero)
true
,
the string "-0.0"
may be returned for some input numbers. If false
, only "0.0"
will be returned, regardless of the sign of the input number. The default value is true
.signedZero
- if true
, the zero string may be returned with a preceding minus sign;
if false
, the zero string will only be returned in its positive formpublic DoubleFormat.Builder alwaysIncludeExponent(boolean alwaysIncludeExponent)
SCIENTIFIC
,
ENGINEERING
, and
MIXED
. The default value is false
.alwaysIncludeExponent
- if true
, exponents will always be included in formatted
output even if the exponent value is zeropublic DoubleFunction<String> build()
public DoubleFormat.Builder decimalSeparator(char decimalSeparator)
'.'
.decimalSeparator
- decimal separator characterpublic DoubleFormat.Builder digits(String digits)
"0123456789"
.digits
- string containing the digit characters 0-9NullPointerException
- if the argument is null
IllegalArgumentException
- if the argument does not have a length of exactly 10public DoubleFormat.Builder exponentSeparator(String exponentSeparator)
"E"
, as in
"1.2E6"
.exponentSeparator
- exponent separator stringNullPointerException
- if the argument is null
public DoubleFormat.Builder formatSymbols(DecimalFormatSymbols symbols)
digit characters
decimal separator
thousands grouping separator
minus sign
exponent separator
infinity
NaN
zero digit
and adding the next
9 consecutive characters.symbols
- format symbolsNullPointerException
- if the argument is null
public DoubleFormat.Builder groupingSeparator(char groupingSeparator)
','
.groupingSeparator
- character used to separate groups of thousandsgroupThousands(boolean)
public DoubleFormat.Builder groupThousands(boolean groupThousands)
true
, thousands will be grouped with the
grouping separator
. For example, if set to true
,
the number 1000
could be formatted as "1,000"
. This property only applies
to the PLAIN
format. Default value is false
.groupThousands
- if true
, thousands will be groupedgroupingSeparator(char)
public DoubleFormat.Builder includeFractionPlaceholder(boolean fractionPlaceholder)
true
, the number 1
would
be formatted as "1.0"
. If false
, it would be formatted as "1"
. The default
value is true
.fractionPlaceholder
- if true
, a zero character is placed in the fraction position when
no fractional value is present; if false
, fractional digits are only included when neededpublic DoubleFormat.Builder infinity(String infinity)
minus sign
.infinity
- string used to represent infinityNullPointerException
- if the argument is null
public DoubleFormat.Builder maxPrecision(int maxPrecision)
0
indicates no limit. The default value is 0
.maxPrecision
- maximum precisionpublic DoubleFormat.Builder minDecimalExponent(int minDecimalExponent)
10minDecimalExponent
will
be included in format results. If the number being formatted does not contain
any such digits, then zero is returned. For example, if minDecimalExponent
is set to -2
and the number 3.14159
is formatted, the plain
format result will be "3.14"
. If 0.001
is formatted, then the
result is the zero string.minDecimalExponent
- minimum decimal exponentpublic DoubleFormat.Builder minusSign(char minusSign)
minusSign
- character to use as the minus signpublic DoubleFormat.Builder nan(String nan)
Double.NaN
.nan
- string used to represent Double.NaN
NullPointerException
- if the argument is null
public DoubleFormat.Builder plainFormatMaxDecimalExponent(int plainFormatMaxDecimalExponent)
MIXED
format type. If the number being formatted
has an absolute value less than 10plainFormatMaxDecimalExponent + 1
and
greater than or equal to 10plainFormatMinDecimalExponent
after any
necessary rounding, then the formatted result will use the PLAIN
format type.
Otherwise, SCIENTIFIC
format will be used. For example,
if this value is set to 2
, the number 999
will be formatted as "999.0"
while 1000
will be formatted as "1.0E3"
.
The default value is .
This value is ignored for formats other than DoubleFormat.MIXED
.
plainFormatMaxDecimalExponent
- maximum decimal exponent for values formatted as plain
strings when using the MIXED
format type.plainFormatMinDecimalExponent(int)
public DoubleFormat.Builder plainFormatMinDecimalExponent(int plainFormatMinDecimalExponent)
MIXED
format type. If the number being formatted
has an absolute value less than 10plainFormatMaxDecimalExponent + 1
and
greater than or equal to 10plainFormatMinDecimalExponent
after any
necessary rounding, then the formatted result will use the PLAIN
format type.
Otherwise, SCIENTIFIC
format will be used. For example,
if this value is set to -2
, the number 0.01
will be formatted as "0.01"
while 0.0099
will be formatted as "9.9E-3"
.
The default value is .
This value is ignored for formats other than DoubleFormat.MIXED
.
plainFormatMinDecimalExponent
- maximum decimal exponent for values formatted as plain
strings when using the MIXED
format type.plainFormatMinDecimalExponent(int)
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.