public class DecimalFormatProperties extends Object implements Cloneable, Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
DecimalFormatProperties.ParseMode
Controls the set of rules for parsing a string from the old DecimalFormat API.
|
| Constructor and Description |
|---|
DecimalFormatProperties() |
| Modifier and Type | Method and Description |
|---|---|
DecimalFormatProperties |
clear() |
DecimalFormatProperties |
clone()
Creates and returns a shallow copy of the property bag.
|
DecimalFormatProperties |
copyFrom(DecimalFormatProperties other)
Shallow-copies the properties from the given property bag into this property bag.
|
boolean |
equals(Object other) |
Map<String,Map<String,String>> |
getCompactCustomData() |
CompactDecimalFormat.CompactStyle |
getCompactStyle() |
Currency |
getCurrency() |
boolean |
getCurrencyAsDecimal() |
CurrencyPluralInfo |
getCurrencyPluralInfo() |
Currency.CurrencyUsage |
getCurrencyUsage() |
boolean |
getDecimalPatternMatchRequired() |
boolean |
getDecimalSeparatorAlwaysShown() |
boolean |
getExponentSignAlwaysShown() |
int |
getFormatWidth() |
int |
getGroupingSize() |
boolean |
getGroupingUsed() |
int |
getMagnitudeMultiplier() |
MathContext |
getMathContext() |
int |
getMaximumFractionDigits() |
int |
getMaximumIntegerDigits() |
int |
getMaximumSignificantDigits() |
int |
getMinimumExponentDigits() |
int |
getMinimumFractionDigits() |
int |
getMinimumGroupingDigits() |
int |
getMinimumIntegerDigits() |
int |
getMinimumSignificantDigits() |
BigDecimal |
getMultiplier() |
String |
getNegativePrefix() |
String |
getNegativePrefixPattern() |
String |
getNegativeSuffix() |
String |
getNegativeSuffixPattern() |
Padder.PadPosition |
getPadPosition() |
String |
getPadString() |
boolean |
getParseCaseSensitive() |
boolean |
getParseIntegerOnly() |
DecimalFormatProperties.ParseMode |
getParseMode() |
boolean |
getParseNoExponent() |
boolean |
getParseToBigDecimal() |
PluralRules |
getPluralRules() |
String |
getPositivePrefix() |
String |
getPositivePrefixPattern() |
String |
getPositiveSuffix() |
String |
getPositiveSuffixPattern() |
BigDecimal |
getRoundingIncrement() |
RoundingMode |
getRoundingMode() |
int |
getSecondaryGroupingSize() |
boolean |
getSignAlwaysShown() |
int |
hashCode() |
DecimalFormatProperties |
setCompactCustomData(Map<String,Map<String,String>> compactCustomData)
Specifies custom data to be used instead of CLDR data when constructing a CompactDecimalFormat.
|
DecimalFormatProperties |
setCompactStyle(CompactDecimalFormat.CompactStyle compactStyle)
Use compact decimal formatting with the specified
CompactDecimalFormat.CompactStyle. |
DecimalFormatProperties |
setCurrency(Currency currency)
Use the specified currency to substitute currency placeholders ('¤') in the pattern string.
|
DecimalFormatProperties |
setCurrencyAsDecimal(boolean currencyAsDecimal)
Sets whether the currency symbol should replace the decimal separator.
|
DecimalFormatProperties |
setCurrencyPluralInfo(CurrencyPluralInfo currencyPluralInfo)
Use the specified
CurrencyPluralInfo instance when formatting currency long names. |
DecimalFormatProperties |
setCurrencyUsage(Currency.CurrencyUsage currencyUsage)
Use the specified
Currency.CurrencyUsage instance, which provides default rounding rules for the
currency in two styles, CurrencyUsage.CASH and CurrencyUsage.STANDARD. |
DecimalFormatProperties |
setDecimalPatternMatchRequired(boolean decimalPatternMatchRequired)
PARSING: Whether to require that the presence of decimal point matches the pattern.
|
DecimalFormatProperties |
setDecimalSeparatorAlwaysShown(boolean alwaysShowDecimal)
Sets whether to always show the decimal point, even if the number doesn't require one.
|
DecimalFormatProperties |
setExponentSignAlwaysShown(boolean exponentSignAlwaysShown)
Sets whether to show the plus sign in the exponent part of numbers with a zero or positive
exponent.
|
DecimalFormatProperties |
setFormatWidth(int paddingWidth)
Sets the minimum width of the string output by the formatting pipeline.
|
DecimalFormatProperties |
setGroupingSize(int groupingSize)
Sets the number of digits between grouping separators.
|
DecimalFormatProperties |
setGroupingUsed(boolean groupingUsed)
Sets whether to enable grouping when formatting.
|
DecimalFormatProperties |
setMagnitudeMultiplier(int magnitudeMultiplier)
Multiply all numbers by this power of ten before formatting.
|
DecimalFormatProperties |
setMathContext(MathContext mathContext)
Sets the
MathContext to be used during math and rounding operations. |
DecimalFormatProperties |
setMaximumFractionDigits(int maximumFractionDigits)
Sets the maximum number of digits to display after the decimal point.
|
DecimalFormatProperties |
setMaximumIntegerDigits(int maximumIntegerDigits)
Sets the maximum number of digits to display before the decimal point.
|
DecimalFormatProperties |
setMaximumSignificantDigits(int maximumSignificantDigits)
Sets the maximum number of significant digits to display.
|
DecimalFormatProperties |
setMinimumExponentDigits(int minimumExponentDigits)
Sets the minimum number of digits to display in the exponent.
|
DecimalFormatProperties |
setMinimumFractionDigits(int minimumFractionDigits)
Sets the minimum number of digits to display after the decimal point.
|
DecimalFormatProperties |
setMinimumGroupingDigits(int minimumGroupingDigits)
Sets the minimum number of digits required to be beyond the first grouping separator in order to
enable grouping.
|
DecimalFormatProperties |
setMinimumIntegerDigits(int minimumIntegerDigits)
Sets the minimum number of digits to display before the decimal point.
|
DecimalFormatProperties |
setMinimumSignificantDigits(int minimumSignificantDigits)
Sets the minimum number of significant digits to display.
|
DecimalFormatProperties |
setMultiplier(BigDecimal multiplier)
Multiply all numbers by this amount before formatting.
|
DecimalFormatProperties |
setNegativePrefix(String negativePrefix)
Sets the prefix to prepend to negative numbers.
|
DecimalFormatProperties |
setNegativePrefixPattern(String negativePrefixPattern)
Sets the prefix to prepend to negative numbers.
|
DecimalFormatProperties |
setNegativeSuffix(String negativeSuffix)
Sets the suffix to append to negative numbers.
|
DecimalFormatProperties |
setNegativeSuffixPattern(String negativeSuffixPattern)
Sets the suffix to append to negative numbers.
|
DecimalFormatProperties |
setPadPosition(Padder.PadPosition paddingLocation)
Sets the location where the padding string is to be inserted to maintain the padding width: one of
BEFORE_PREFIX, AFTER_PREFIX, BEFORE_SUFFIX, or AFTER_SUFFIX.
|
DecimalFormatProperties |
setPadString(String paddingString)
Sets the string used for padding.
|
DecimalFormatProperties |
setParseCaseSensitive(boolean parseCaseSensitive)
Whether to require cases to match when parsing strings; default is true.
|
DecimalFormatProperties |
setParseIntegerOnly(boolean parseIntegerOnly)
Whether to ignore the fractional part of numbers.
|
DecimalFormatProperties |
setParseMode(DecimalFormatProperties.ParseMode parseMode)
Controls certain rules for how strict this parser is when reading strings.
|
DecimalFormatProperties |
setParseNoExponent(boolean parseNoExponent)
Whether to ignore the exponential part of numbers.
|
DecimalFormatProperties |
setParseToBigDecimal(boolean parseToBigDecimal)
Whether to always return a BigDecimal from parse methods.
|
DecimalFormatProperties |
setPluralRules(PluralRules pluralRules)
Sets the PluralRules object to use instead of the default for the locale.
|
DecimalFormatProperties |
setPositivePrefix(String positivePrefix)
Sets the prefix to prepend to positive numbers.
|
DecimalFormatProperties |
setPositivePrefixPattern(String positivePrefixPattern)
Sets the prefix to prepend to positive numbers.
|
DecimalFormatProperties |
setPositiveSuffix(String positiveSuffix)
Sets the suffix to append to positive numbers.
|
DecimalFormatProperties |
setPositiveSuffixPattern(String positiveSuffixPattern)
Sets the suffix to append to positive numbers.
|
DecimalFormatProperties |
setRoundingIncrement(BigDecimal roundingIncrement)
Sets the increment to which to round numbers.
|
DecimalFormatProperties |
setRoundingMode(RoundingMode roundingMode)
Sets the rounding mode, which determines under which conditions extra decimal places are rounded
either up or down.
|
DecimalFormatProperties |
setSecondaryGroupingSize(int secondaryGroupingSize)
Sets the number of digits between grouping separators higher than the least-significant grouping
separator.
|
DecimalFormatProperties |
setSignAlwaysShown(boolean signAlwaysShown)
Sets whether to always display of a plus sign on positive numbers.
|
String |
toString() |
void |
toStringBare(StringBuilder result)
Appends a string containing properties that differ from the default, but without being surrounded
by <Properties>.
|
public DecimalFormatProperties clear()
public DecimalFormatProperties clone()
public DecimalFormatProperties copyFrom(DecimalFormatProperties other)
other - The property bag from which to copy and which will not be modified.public CompactDecimalFormat.CompactStyle getCompactStyle()
public Currency getCurrency()
public CurrencyPluralInfo getCurrencyPluralInfo()
public Currency.CurrencyUsage getCurrencyUsage()
public boolean getDecimalPatternMatchRequired()
public boolean getDecimalSeparatorAlwaysShown()
public boolean getExponentSignAlwaysShown()
public boolean getCurrencyAsDecimal()
public int getFormatWidth()
public int getGroupingSize()
public boolean getGroupingUsed()
public int getMagnitudeMultiplier()
public MathContext getMathContext()
public int getMaximumFractionDigits()
public int getMaximumIntegerDigits()
public int getMaximumSignificantDigits()
public int getMinimumExponentDigits()
public int getMinimumFractionDigits()
public int getMinimumGroupingDigits()
public int getMinimumIntegerDigits()
public int getMinimumSignificantDigits()
public BigDecimal getMultiplier()
public String getNegativePrefix()
public String getNegativePrefixPattern()
public String getNegativeSuffix()
public String getNegativeSuffixPattern()
public Padder.PadPosition getPadPosition()
public String getPadString()
public boolean getParseCaseSensitive()
public boolean getParseIntegerOnly()
public DecimalFormatProperties.ParseMode getParseMode()
public boolean getParseNoExponent()
public boolean getParseToBigDecimal()
public PluralRules getPluralRules()
public String getPositivePrefix()
public String getPositivePrefixPattern()
public String getPositiveSuffix()
public String getPositiveSuffixPattern()
public BigDecimal getRoundingIncrement()
public RoundingMode getRoundingMode()
public int getSecondaryGroupingSize()
public boolean getSignAlwaysShown()
public DecimalFormatProperties setCompactCustomData(Map<String,Map<String,String>> compactCustomData)
{
"1000": {
"one": "0 thousand",
"other": "0 thousand"
},
"10000": {
"one": "00 thousand",
"other": "00 thousand"
},
// ...
}
This API endpoint is used by the CLDR Survey Tool.compactCustomData - A map with the above structure.public DecimalFormatProperties setCompactStyle(CompactDecimalFormat.CompactStyle compactStyle)
CompactDecimalFormat.CompactStyle. CompactStyle.SHORT
produces output like "10K" in locale en-US, whereas CompactStyle.LONG produces output
like "10 thousand" in that locale.compactStyle - The style of prefixes/suffixes to append.public DecimalFormatProperties setCurrency(Currency currency)
currency - The currency.public DecimalFormatProperties setCurrencyPluralInfo(CurrencyPluralInfo currencyPluralInfo)
CurrencyPluralInfo instance when formatting currency long names.currencyPluralInfo - The currency plural info object.public DecimalFormatProperties setCurrencyUsage(Currency.CurrencyUsage currencyUsage)
Currency.CurrencyUsage instance, which provides default rounding rules for the
currency in two styles, CurrencyUsage.CASH and CurrencyUsage.STANDARD.
The CurrencyUsage specified here will not be used unless there is a currency placeholder in the pattern.
currencyUsage - The currency usage. Defaults to CurrencyUsage.STANDARD.public DecimalFormatProperties setDecimalPatternMatchRequired(boolean decimalPatternMatchRequired)
parse(), and an error index will be set in the
ParsePosition.decimalPatternMatchRequired - true to set an error if decimal is not presentpublic DecimalFormatProperties setDecimalSeparatorAlwaysShown(boolean alwaysShowDecimal)
alwaysShowDecimal - Whether to show the decimal point when it is optional.public DecimalFormatProperties setExponentSignAlwaysShown(boolean exponentSignAlwaysShown)
exponentSignAlwaysShown - Whether to show the plus sign in positive exponents.public DecimalFormatProperties setCurrencyAsDecimal(boolean currencyAsDecimal)
currencyAsDecimal - Whether the currency symbol should replace the decimal separator.public DecimalFormatProperties setFormatWidth(int paddingWidth)
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.
Width is counted in UTF-16 code units.
paddingWidth - The output width.DecimalFormatProperties.setPadPosition(org.graalvm.shadowed.com.ibm.icu.impl.number.Padder.PadPosition),
DecimalFormatProperties.setPadString(java.lang.String)public DecimalFormatProperties setGroupingSize(int groupingSize)
DecimalFormatProperties.setSecondaryGroupingSize(int).groupingSize - The primary grouping size.public DecimalFormatProperties setGroupingUsed(boolean groupingUsed)
groupingUsed - true to enable the display of grouping separators; false to disable.public DecimalFormatProperties setMagnitudeMultiplier(int magnitudeMultiplier)
magnitudeMultiplier - The number of powers of ten to scale.DecimalFormatProperties.setMultiplier(java.math.BigDecimal)public DecimalFormatProperties setMathContext(MathContext mathContext)
MathContext to be used during math and rounding operations. A MathContext
encapsulates a RoundingMode and the number of significant digits in the output.mathContext - The math context to use when rounding is required.MathContext,
DecimalFormatProperties.setRoundingMode(java.math.RoundingMode)public DecimalFormatProperties setMaximumFractionDigits(int maximumFractionDigits)
DecimalFormatProperties.setRoundingMode(RoundingMode). The pattern "#00.0#", for example, corresponds to 2
maximum fraction digits, and the number 456.789 would be formatted as "456.79" in locale
en-US with the default rounding mode. Note that the number 456.999 would be formatted as
"457.0" given the same configurations.maximumFractionDigits - The maximum number of fraction digits to output.public DecimalFormatProperties setMaximumIntegerDigits(int maximumIntegerDigits)
maximumIntegerDigits - The maximum number of integer digits to output.public DecimalFormatProperties setMaximumSignificantDigits(int maximumSignificantDigits)
DecimalFormatProperties.setRoundingMode(RoundingMode). For example, if maximum
significant digits is 3, the number 1234.56 will be formatted as "1230" in locale en-US
with the default rounding mode.
If both maximum significant digits and maximum integer/fraction digits are set at the same time, the behavior is undefined.
The number of significant digits can be specified in a pattern string using the '@' character. For example, the pattern "@@#" corresponds to a minimum of 2 and a maximum of 3 significant digits.
maximumSignificantDigits - The maximum number of significant digits to display.public DecimalFormatProperties setMinimumExponentDigits(int minimumExponentDigits)
minimumExponentDigits - The minimum number of digits to display in the exponent field.public DecimalFormatProperties setMinimumFractionDigits(int minimumFractionDigits)
minimumFractionDigits - The minimum number of fraction digits to output.public DecimalFormatProperties setMinimumGroupingDigits(int minimumGroupingDigits)
minimumGroupingDigits - How many digits must appear before a grouping separator before enabling grouping.public DecimalFormatProperties setMinimumIntegerDigits(int minimumIntegerDigits)
minimumIntegerDigits - The minimum number of integer digits to output.public DecimalFormatProperties setMinimumSignificantDigits(int minimumSignificantDigits)
DecimalFormatProperties.setMaximumSignificantDigits(int), the number of remaining
significant digits is less than the minimum, the number will be padded with zeros. For example, if
minimum significant digits is 3, the number 5.8 will be formatted as "5.80" in locale
en-US. Note that minimum significant digits is relevant only when numbers have digits
after the decimal point.
If both minimum significant digits and minimum integer/fraction digits are set at the same time, both values will be respected, and the one that results in the greater number of padding zeros will be used. For example, formatting the number 73 with 3 minimum significant digits and 2 minimum fraction digits will produce "73.00".
The number of significant digits can be specified in a pattern string using the '@' character. For example, the pattern "@@#" corresponds to a minimum of 2 and a maximum of 3 significant digits.
minimumSignificantDigits - The minimum number of significant digits to display.public DecimalFormatProperties setMultiplier(BigDecimal multiplier)
multiplier - The amount to multiply by.DecimalFormatProperties.setMagnitudeMultiplier(int)public DecimalFormatProperties setNegativePrefix(String negativePrefix)
n, then the number -123 will be formatted as
"n123" in the locale en-US. Note that if the negative prefix is left unset, the locale's
minus sign is used.
For more information on prefixes and suffixes, see MutablePatternModifier.
negativePrefix - The CharSequence to prepend to negative numbers.DecimalFormatProperties.setNegativePrefixPattern(java.lang.String)public DecimalFormatProperties setNegativePrefixPattern(String negativePrefixPattern)
For more information on prefixes and suffixes, see MutablePatternModifier.
negativePrefixPattern - The CharSequence to prepend to negative numbers after locale symbol substitutions take
place.DecimalFormatProperties.setNegativePrefix(java.lang.String)public DecimalFormatProperties setNegativeSuffix(String negativeSuffix)
n, then the number -123 will be formatted as
"-123n" in the locale en-US. Note that the minus sign is prepended by default unless
otherwise specified in either the pattern string or in one of the DecimalFormatProperties.setNegativePrefix(java.lang.String)
methods.
For more information on prefixes and suffixes, see MutablePatternModifier.
negativeSuffix - The CharSequence to append to negative numbers.DecimalFormatProperties.setNegativeSuffixPattern(java.lang.String)public DecimalFormatProperties setNegativeSuffixPattern(String negativeSuffixPattern)
For more information on prefixes and suffixes, see MutablePatternModifier.
negativeSuffixPattern - The CharSequence to append to negative numbers after locale symbol substitutions take
place.DecimalFormatProperties.setNegativeSuffix(java.lang.String)public DecimalFormatProperties setPadPosition(Padder.PadPosition paddingLocation)
Must be used in conjunction with DecimalFormatProperties.setFormatWidth(int).
paddingLocation - The output width.DecimalFormatProperties.setFormatWidth(int)public DecimalFormatProperties setPadString(String paddingString)
Must be used in conjunction with DecimalFormatProperties.setFormatWidth(int).
paddingString - The padding string. Defaults to an ASCII space (U+0020).DecimalFormatProperties.setFormatWidth(int)public DecimalFormatProperties setParseCaseSensitive(boolean parseCaseSensitive)
This setting is ignored in fast mode. In fast mode, strings are always compared in a case-sensitive way.
parseCaseSensitive - true to be case-sensitive when parsing; false to allow any case.public DecimalFormatProperties setParseIntegerOnly(boolean parseIntegerOnly)
parseIntegerOnly - true to parse integers only; false to parse integers with their fraction partspublic DecimalFormatProperties setParseMode(DecimalFormatProperties.ParseMode parseMode)
DecimalFormatProperties.ParseMode.LENIENT and DecimalFormatProperties.ParseMode.STRICT.parseMode - Either DecimalFormatProperties.ParseMode.LENIENT or DecimalFormatProperties.ParseMode.STRICT.public DecimalFormatProperties setParseNoExponent(boolean parseNoExponent)
parseNoExponent - true to ignore exponents; false to parse them.public DecimalFormatProperties setParseToBigDecimal(boolean parseToBigDecimal)
parseToBigDecimal - true to always return a BigDecimal; false to return a Long or a BigInteger when
possible.public DecimalFormatProperties setPluralRules(PluralRules pluralRules)
pluralRules - The object to reference.public DecimalFormatProperties setPositivePrefix(String positivePrefix)
p, then the number 123 will be formatted as
"p123" in the locale en-US.
For more information on prefixes and suffixes, see MutablePatternModifier.
positivePrefix - The CharSequence to prepend to positive numbers.DecimalFormatProperties.setPositivePrefixPattern(java.lang.String)public DecimalFormatProperties setPositivePrefixPattern(String positivePrefixPattern)
For more information on prefixes and suffixes, see MutablePatternModifier.
positivePrefixPattern - The CharSequence to prepend to positive numbers after locale symbol substitutions take
place.DecimalFormatProperties.setPositivePrefix(java.lang.String)public DecimalFormatProperties setPositiveSuffix(String positiveSuffix)
p, then the number 123 will be formatted as
"123p" in the locale en-US.
For more information on prefixes and suffixes, see MutablePatternModifier.
positiveSuffix - The CharSequence to append to positive numbers.DecimalFormatProperties.setPositiveSuffixPattern(java.lang.String)public DecimalFormatProperties setPositiveSuffixPattern(String positiveSuffixPattern)
For more information on prefixes and suffixes, see MutablePatternModifier.
positiveSuffixPattern - The CharSequence to append to positive numbers after locale symbol substitutions take
place.DecimalFormatProperties.setPositiveSuffix(java.lang.String)public DecimalFormatProperties setRoundingIncrement(BigDecimal roundingIncrement)
You can use either a rounding increment or significant digits, but not both at the same time.
The rounding increment can be specified in a pattern string. For example, the pattern "#,##0.05" corresponds to a rounding interval of 0.05 with 1 minimum integer digit and a grouping size of 3.
roundingIncrement - The interval to which to round.public DecimalFormatProperties setRoundingMode(RoundingMode roundingMode)
RoundingMode for details on the choices of rounding mode. The
default if not set explicitly is RoundingMode.HALF_EVEN.
This setting is ignored if DecimalFormatProperties.setMathContext(java.math.MathContext) is used.
roundingMode - The rounding mode to use when rounding is required.RoundingMode,
DecimalFormatProperties.setMathContext(java.math.MathContext)public DecimalFormatProperties setSecondaryGroupingSize(int secondaryGroupingSize)
The two levels of grouping separators can be specified in the pattern string. For example, the hi locale's default decimal format pattern is "#,##,##0.###".
secondaryGroupingSize - The secondary grouping size.public DecimalFormatProperties setSignAlwaysShown(boolean signAlwaysShown)
If the location of the negative sign is specified by the decimal format pattern (or by the
negative prefix/suffix pattern methods), a plus sign is substituted into that location, in
accordance with Unicode Technical Standard #35 (LDML) section 3.2.1. Otherwise, the plus sign is
prepended to the number. For example, if the decimal format pattern #;#- is used,
then formatting 123 would result in "123+" in the locale en-US.
This method should be used instead of setting the positive prefix/suffix. The behavior is undefined if alwaysShowPlusSign is set but the positive prefix/suffix already contains a plus sign.
signAlwaysShown - Whether positive numbers should display a plus sign.public void toStringBare(StringBuilder result)