Class DecimalFormatProperties
- All Implemented Interfaces:
Serializable
,Cloneable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Controls the set of rules for parsing a string from the old DecimalFormat API. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Currency
private boolean
private CurrencyPluralInfo
private Currency.CurrencyUsage
private boolean
private boolean
private static final DecimalFormatProperties
private boolean
private int
private int
private boolean
private int
private MathContext
private int
private int
private int
private int
private int
private int
private int
private int
private BigDecimal
private String
private String
private String
private String
private Padder.PadPosition
private String
private boolean
private boolean
private boolean
private boolean
private PluralRules
private String
private String
private String
private String
private BigDecimal
private RoundingMode
private int
private static final long
Auto-generated.private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate DecimalFormatProperties
_clear()
Sets all properties to their defaults (unset).private DecimalFormatProperties
_copyFrom
(DecimalFormatProperties other) private boolean
_equals
(DecimalFormatProperties other) private boolean
_equalsHelper
(boolean mine, boolean theirs) private boolean
_equalsHelper
(int mine, int theirs) private boolean
_equalsHelper
(Object mine, Object theirs) private int
private int
_hashCodeHelper
(boolean value) private int
_hashCodeHelper
(int value) private int
_hashCodeHelper
(Object value) clear()
clone()
Creates and returns a shallow copy of the property bag.copyFrom
(DecimalFormatProperties other) Shallow-copies the properties from the given property bag into this property bag.boolean
boolean
boolean
boolean
boolean
int
int
boolean
int
int
int
int
int
int
int
int
int
boolean
boolean
boolean
boolean
int
boolean
int
hashCode()
private void
Custom serialization: re-create object from serialized properties.(package private) void
Specifies custom data to be used instead of CLDR data when constructing a CompactDecimalFormat.setCompactStyle
(CompactDecimalFormat.CompactStyle compactStyle) Use compact decimal formatting with the specifiedCompactDecimalFormat.CompactStyle
.setCurrency
(Currency currency) Use the specified currency to substitute currency placeholders ('¤') in the pattern string.setCurrencyAsDecimal
(boolean currencyAsDecimal) Sets whether the currency symbol should replace the decimal separator.setCurrencyPluralInfo
(CurrencyPluralInfo currencyPluralInfo) Use the specifiedCurrencyPluralInfo
instance when formatting currency long names.setCurrencyUsage
(Currency.CurrencyUsage currencyUsage) Use the specifiedCurrency.CurrencyUsage
instance, which provides default rounding rules for the currency in two styles, CurrencyUsage.CASH and CurrencyUsage.STANDARD.setDecimalPatternMatchRequired
(boolean decimalPatternMatchRequired) PARSING: Whether to require that the presence of decimal point matches the pattern.setDecimalSeparatorAlwaysShown
(boolean alwaysShowDecimal) Sets whether to always show the decimal point, even if the number doesn't require one.setExponentSignAlwaysShown
(boolean exponentSignAlwaysShown) Sets whether to show the plus sign in the exponent part of numbers with a zero or positive exponent.setFormatWidth
(int paddingWidth) Sets the minimum width of the string output by the formatting pipeline.setGroupingSize
(int groupingSize) Sets the number of digits between grouping separators.setGroupingUsed
(boolean groupingUsed) Sets whether to enable grouping when formatting.setMagnitudeMultiplier
(int magnitudeMultiplier) Multiply all numbers by this power of ten before formatting.setMathContext
(MathContext mathContext) Sets theMathContext
to be used during math and rounding operations.setMaximumFractionDigits
(int maximumFractionDigits) Sets the maximum number of digits to display after the decimal point.setMaximumIntegerDigits
(int maximumIntegerDigits) Sets the maximum number of digits to display before the decimal point.setMaximumSignificantDigits
(int maximumSignificantDigits) Sets the maximum number of significant digits to display.setMinimumExponentDigits
(int minimumExponentDigits) Sets the minimum number of digits to display in the exponent.setMinimumFractionDigits
(int minimumFractionDigits) Sets the minimum number of digits to display after the decimal point.setMinimumGroupingDigits
(int minimumGroupingDigits) Sets the minimum number of digits required to be beyond the first grouping separator in order to enable grouping.setMinimumIntegerDigits
(int minimumIntegerDigits) Sets the minimum number of digits to display before the decimal point.setMinimumSignificantDigits
(int minimumSignificantDigits) Sets the minimum number of significant digits to display.setMultiplier
(BigDecimal multiplier) Multiply all numbers by this amount before formatting.setNegativePrefix
(String negativePrefix) Sets the prefix to prepend to negative numbers.setNegativePrefixPattern
(String negativePrefixPattern) Sets the prefix to prepend to negative numbers.setNegativeSuffix
(String negativeSuffix) Sets the suffix to append to negative numbers.setNegativeSuffixPattern
(String negativeSuffixPattern) Sets the suffix to append to negative numbers.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.setPadString
(String paddingString) Sets the string used for padding.setParseCaseSensitive
(boolean parseCaseSensitive) Whether to require cases to match when parsing strings; default is true.setParseIntegerOnly
(boolean parseIntegerOnly) Whether to ignore the fractional part of numbers.setParseMode
(DecimalFormatProperties.ParseMode parseMode) Controls certain rules for how strict this parser is when reading strings.setParseNoExponent
(boolean parseNoExponent) Whether to ignore the exponential part of numbers.setParseToBigDecimal
(boolean parseToBigDecimal) Whether to always return a BigDecimal from parse methods.setPluralRules
(PluralRules pluralRules) Sets the PluralRules object to use instead of the default for the locale.setPositivePrefix
(String positivePrefix) Sets the prefix to prepend to positive numbers.setPositivePrefixPattern
(String positivePrefixPattern) Sets the prefix to prepend to positive numbers.setPositiveSuffix
(String positiveSuffix) Sets the suffix to append to positive numbers.setPositiveSuffixPattern
(String positiveSuffixPattern) Sets the suffix to append to positive numbers.setRoundingIncrement
(BigDecimal roundingIncrement) Sets the increment to which to round numbers.setRoundingMode
(RoundingMode roundingMode) Sets the rounding mode, which determines under which conditions extra decimal places are rounded either up or down.setSecondaryGroupingSize
(int secondaryGroupingSize) Sets the number of digits between grouping separators higher than the least-significant grouping separator.setSignAlwaysShown
(boolean signAlwaysShown) Sets whether to always display of a plus sign on positive numbers.toString()
void
toStringBare
(StringBuilder result) Appends a string containing properties that differ from the default, but without being surrounded by <Properties>.private void
Custom serialization: save fields along with their name, so that fields can be easily added in the future in any order.(package private) void
-
Field Details
-
DEFAULT
-
serialVersionUID
private static final long serialVersionUIDAuto-generated.- See Also:
-
compactCustomData
-
compactStyle
-
currency
-
currencyPluralInfo
-
currencyUsage
-
decimalPatternMatchRequired
private transient boolean decimalPatternMatchRequired -
decimalSeparatorAlwaysShown
private transient boolean decimalSeparatorAlwaysShown -
exponentSignAlwaysShown
private transient boolean exponentSignAlwaysShown -
currencyAsDecimal
private transient boolean currencyAsDecimal -
formatWidth
private transient int formatWidth -
groupingSize
private transient int groupingSize -
groupingUsed
private transient boolean groupingUsed -
magnitudeMultiplier
private transient int magnitudeMultiplier -
mathContext
-
maximumFractionDigits
private transient int maximumFractionDigits -
maximumIntegerDigits
private transient int maximumIntegerDigits -
maximumSignificantDigits
private transient int maximumSignificantDigits -
minimumExponentDigits
private transient int minimumExponentDigits -
minimumFractionDigits
private transient int minimumFractionDigits -
minimumGroupingDigits
private transient int minimumGroupingDigits -
minimumIntegerDigits
private transient int minimumIntegerDigits -
minimumSignificantDigits
private transient int minimumSignificantDigits -
multiplier
-
negativePrefix
-
negativePrefixPattern
-
negativeSuffix
-
negativeSuffixPattern
-
padPosition
-
padString
-
parseCaseSensitive
private transient boolean parseCaseSensitive -
parseIntegerOnly
private transient boolean parseIntegerOnly -
parseMode
-
parseNoExponent
private transient boolean parseNoExponent -
parseToBigDecimal
private transient boolean parseToBigDecimal -
pluralRules
-
positivePrefix
-
positivePrefixPattern
-
positiveSuffix
-
positiveSuffixPattern
-
roundingIncrement
-
roundingMode
-
secondaryGroupingSize
private transient int secondaryGroupingSize -
signAlwaysShown
private transient boolean signAlwaysShown
-
-
Constructor Details
-
DecimalFormatProperties
public DecimalFormatProperties()
-
-
Method Details
-
_clear
Sets all properties to their defaults (unset).All integers default to -1 EXCEPT FOR MAGNITUDE MULTIPLIER which has a default of 0 (since negative numbers are important).
All booleans default to false.
All non-primitive types default to null.
- Returns:
- The property bag, for chaining.
-
_copyFrom
-
_equals
-
_equalsHelper
private boolean _equalsHelper(boolean mine, boolean theirs) -
_equalsHelper
private boolean _equalsHelper(int mine, int theirs) -
_equalsHelper
-
_hashCode
private int _hashCode() -
_hashCodeHelper
private int _hashCodeHelper(boolean value) -
_hashCodeHelper
private int _hashCodeHelper(int value) -
_hashCodeHelper
-
clear
-
clone
Creates and returns a shallow copy of the property bag. -
copyFrom
Shallow-copies the properties from the given property bag into this property bag.- Parameters:
other
- The property bag from which to copy and which will not be modified.- Returns:
- The current property bag (the one modified by this operation), for chaining.
-
equals
-
getCompactCustomData
-
getCompactStyle
-
getCurrency
-
getCurrencyPluralInfo
-
getCurrencyUsage
-
getDecimalPatternMatchRequired
public boolean getDecimalPatternMatchRequired() -
getDecimalSeparatorAlwaysShown
public boolean getDecimalSeparatorAlwaysShown() -
getExponentSignAlwaysShown
public boolean getExponentSignAlwaysShown() -
getCurrencyAsDecimal
public boolean getCurrencyAsDecimal() -
getFormatWidth
public int getFormatWidth() -
getGroupingSize
public int getGroupingSize() -
getGroupingUsed
public boolean getGroupingUsed() -
getMagnitudeMultiplier
public int getMagnitudeMultiplier() -
getMathContext
-
getMaximumFractionDigits
public int getMaximumFractionDigits() -
getMaximumIntegerDigits
public int getMaximumIntegerDigits() -
getMaximumSignificantDigits
public int getMaximumSignificantDigits() -
getMinimumExponentDigits
public int getMinimumExponentDigits() -
getMinimumFractionDigits
public int getMinimumFractionDigits() -
getMinimumGroupingDigits
public int getMinimumGroupingDigits() -
getMinimumIntegerDigits
public int getMinimumIntegerDigits() -
getMinimumSignificantDigits
public int getMinimumSignificantDigits() -
getMultiplier
-
getNegativePrefix
-
getNegativePrefixPattern
-
getNegativeSuffix
-
getNegativeSuffixPattern
-
getPadPosition
-
getPadString
-
getParseCaseSensitive
public boolean getParseCaseSensitive() -
getParseIntegerOnly
public boolean getParseIntegerOnly() -
getParseMode
-
getParseNoExponent
public boolean getParseNoExponent() -
getParseToBigDecimal
public boolean getParseToBigDecimal() -
getPluralRules
-
getPositivePrefix
-
getPositivePrefixPattern
-
getPositiveSuffix
-
getPositiveSuffixPattern
-
getRoundingIncrement
-
getRoundingMode
-
getSecondaryGroupingSize
public int getSecondaryGroupingSize() -
getSignAlwaysShown
public boolean getSignAlwaysShown() -
hashCode
public int hashCode() -
readObject
Custom serialization: re-create object from serialized properties.- Throws:
IOException
ClassNotFoundException
-
readObjectImpl
- Throws:
IOException
ClassNotFoundException
-
setCompactCustomData
public DecimalFormatProperties setCompactCustomData(Map<String, Map<String, String>> compactCustomData) Specifies custom data to be used instead of CLDR data when constructing a CompactDecimalFormat. The argument should be a map with the following structure:{ "1000": { "one": "0 thousand", "other": "0 thousand" }, "10000": { "one": "00 thousand", "other": "00 thousand" }, // ... }
This API endpoint is used by the CLDR Survey Tool.- Parameters:
compactCustomData
- A map with the above structure.- Returns:
- The property bag, for chaining.
-
setCompactStyle
Use compact decimal formatting with the specifiedCompactDecimalFormat.CompactStyle
. CompactStyle.SHORT produces output like "10K" in locale en-US, whereas CompactStyle.LONG produces output like "10 thousand" in that locale.- Parameters:
compactStyle
- The style of prefixes/suffixes to append.- Returns:
- The property bag, for chaining.
-
setCurrency
Use the specified currency to substitute currency placeholders ('¤') in the pattern string.- Parameters:
currency
- The currency.- Returns:
- The property bag, for chaining.
-
setCurrencyPluralInfo
Use the specifiedCurrencyPluralInfo
instance when formatting currency long names.- Parameters:
currencyPluralInfo
- The currency plural info object.- Returns:
- The property bag, for chaining.
-
setCurrencyUsage
Use the specifiedCurrency.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.
- Parameters:
currencyUsage
- The currency usage. Defaults to CurrencyUsage.STANDARD.- Returns:
- The property bag, for chaining.
-
setDecimalPatternMatchRequired
PARSING: Whether to require that the presence of decimal point matches the pattern. If a decimal point is not present, but the pattern contained a decimal point, parse will not succeed: null will be returned fromparse()
, and an error index will be set in theParsePosition
.- Parameters:
decimalPatternMatchRequired
- true to set an error if decimal is not present- Returns:
- The property bag, for chaining.
-
setDecimalSeparatorAlwaysShown
Sets whether to always show the decimal point, even if the number doesn't require one. For example, if always show decimal is true, the number 123 would be formatted as "123." in locale en-US.- Parameters:
alwaysShowDecimal
- Whether to show the decimal point when it is optional.- Returns:
- The property bag, for chaining.
-
setExponentSignAlwaysShown
Sets whether to show the plus sign in the exponent part of numbers with a zero or positive exponent. For example, the number "1200" with the pattern "0.0E0" would be formatted as "1.2E+3" instead of "1.2E3" in en-US.- Parameters:
exponentSignAlwaysShown
- Whether to show the plus sign in positive exponents.- Returns:
- The property bag, for chaining.
-
setCurrencyAsDecimal
Sets whether the currency symbol should replace the decimal separator.- Parameters:
currencyAsDecimal
- Whether the currency symbol should replace the decimal separator.- Returns:
- The property bag, for chaining.
-
setFormatWidth
Sets the minimum width of the string output by the formatting pipeline. For example, if padding is enabled and paddingWidth is set to 6, formatting the number "3.14159" with the pattern "0.00" will result in "··3.14" if '·' is your padding string.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.
- Parameters:
paddingWidth
- The output width.- Returns:
- The property bag, for chaining.
- See Also:
-
setGroupingSize
Sets the number of digits between grouping separators. For example, the en-US locale uses a grouping size of 3, so the number 1234567 would be formatted as "1,234,567". For locales whose grouping sizes vary with magnitude, seesetSecondaryGroupingSize(int)
.- Parameters:
groupingSize
- The primary grouping size.- Returns:
- The property bag, for chaining.
-
setGroupingUsed
Sets whether to enable grouping when formatting.- Parameters:
groupingUsed
- true to enable the display of grouping separators; false to disable.- Returns:
- The property bag, for chaining.
-
setMagnitudeMultiplier
Multiply all numbers by this power of ten before formatting. Negative multipliers reduce the magnitude and make numbers smaller (closer to zero).- Parameters:
magnitudeMultiplier
- The number of powers of ten to scale.- Returns:
- The property bag, for chaining.
- See Also:
-
setMathContext
Sets theMathContext
to be used during math and rounding operations. A MathContext encapsulates a RoundingMode and the number of significant digits in the output.- Parameters:
mathContext
- The math context to use when rounding is required.- Returns:
- The property bag, for chaining.
- See Also:
-
setMaximumFractionDigits
Sets the maximum number of digits to display after the decimal point. If the number has fewer than this number of digits, the number will be rounded off using the rounding mode specified bysetRoundingMode(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.- Parameters:
maximumFractionDigits
- The maximum number of fraction digits to output.- Returns:
- The property bag, for chaining.
-
setMaximumIntegerDigits
Sets the maximum number of digits to display before the decimal point. If the number has more than this number of digits, the extra digits will be truncated. For example, if maximum integer digits is 2, and you attempt to format the number 1970, you will get "70" in locale en-US. It is not possible to specify the maximum integer digits using a pattern string, except in the special case of a scientific format pattern.- Parameters:
maximumIntegerDigits
- The maximum number of integer digits to output.- Returns:
- The property bag, for chaining.
-
setMaximumSignificantDigits
Sets the maximum number of significant digits to display. The number of significant digits is equal to the number of digits counted from the leftmost nonzero digit through the rightmost nonzero digit; for example, the number "2010" has 3 significant digits. If the number has more significant digits than specified here, the extra significant digits will be rounded off using the rounding mode specified bysetRoundingMode(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.
- Parameters:
maximumSignificantDigits
- The maximum number of significant digits to display.- Returns:
- The property bag, for chaining.
-
setMinimumExponentDigits
Sets the minimum number of digits to display in the exponent. For example, the number "1200" with the pattern "0.0E00", which has 2 exponent digits, would be formatted as "1.2E03" in en-US.- Parameters:
minimumExponentDigits
- The minimum number of digits to display in the exponent field.- Returns:
- The property bag, for chaining.
-
setMinimumFractionDigits
Sets the minimum number of digits to display after the decimal point. If the number has fewer than this number of digits, the number will be padded with zeros. The pattern "#00.0#", for example, corresponds to 1 minimum fraction digit, and the number 456 would be formatted as "456.0" in locale en-US.- Parameters:
minimumFractionDigits
- The minimum number of fraction digits to output.- Returns:
- The property bag, for chaining.
-
setMinimumGroupingDigits
Sets the minimum number of digits required to be beyond the first grouping separator in order to enable grouping. For example, if the minimum grouping digits is 2, then 1234 would be formatted as "1234" but 12345 would be formatted as "12,345" in en-US. Note that 1234567 would still be formatted as "1,234,567", not "1234,567".- Parameters:
minimumGroupingDigits
- How many digits must appear before a grouping separator before enabling grouping.- Returns:
- The property bag, for chaining.
-
setMinimumIntegerDigits
Sets the minimum number of digits to display before the decimal point. If the number has fewer than this number of digits, the number will be padded with zeros. The pattern "#00.0#", for example, corresponds to 2 minimum integer digits, and the number 5.3 would be formatted as "05.3" in locale en-US.- Parameters:
minimumIntegerDigits
- The minimum number of integer digits to output.- Returns:
- The property bag, for chaining.
-
setMinimumSignificantDigits
Sets the minimum number of significant digits to display. If, after rounding to the number of significant digits specified bysetMaximumSignificantDigits(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.
- Parameters:
minimumSignificantDigits
- The minimum number of significant digits to display.- Returns:
- The property bag, for chaining.
-
setMultiplier
Multiply all numbers by this amount before formatting.- Parameters:
multiplier
- The amount to multiply by.- Returns:
- The property bag, for chaining.
- See Also:
-
setNegativePrefix
Sets the prefix to prepend to negative numbers. The prefix will be interpreted literally. For example, if you set a negative prefix ofn
, 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
.- Parameters:
negativePrefix
- The CharSequence to prepend to negative numbers.- Returns:
- The property bag, for chaining.
- See Also:
-
setNegativePrefixPattern
Sets the prefix to prepend to negative numbers. Locale-specific symbols will be substituted into the string according to Unicode Technical Standard #35 (LDML).For more information on prefixes and suffixes, see
MutablePatternModifier
.- Parameters:
negativePrefixPattern
- The CharSequence to prepend to negative numbers after locale symbol substitutions take place.- Returns:
- The property bag, for chaining.
- See Also:
-
setNegativeSuffix
Sets the suffix to append to negative numbers. The suffix will be interpreted literally. For example, if you set a suffix prefix ofn
, 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 thesetNegativePrefix(java.lang.String)
methods.For more information on prefixes and suffixes, see
MutablePatternModifier
.- Parameters:
negativeSuffix
- The CharSequence to append to negative numbers.- Returns:
- The property bag, for chaining.
- See Also:
-
setNegativeSuffixPattern
Sets the suffix to append to negative numbers. Locale-specific symbols will be substituted into the string according to Unicode Technical Standard #35 (LDML).For more information on prefixes and suffixes, see
MutablePatternModifier
.- Parameters:
negativeSuffixPattern
- The CharSequence to append to negative numbers after locale symbol substitutions take place.- Returns:
- The property bag, for chaining.
- See Also:
-
setPadPosition
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.Must be used in conjunction with
setFormatWidth(int)
.- Parameters:
paddingLocation
- The output width.- Returns:
- The property bag, for chaining.
- See Also:
-
setPadString
Sets the string used for padding. The string should contain a single character or grapheme cluster.Must be used in conjunction with
setFormatWidth(int)
.- Parameters:
paddingString
- The padding string. Defaults to an ASCII space (U+0020).- Returns:
- The property bag, for chaining.
- See Also:
-
setParseCaseSensitive
Whether to require cases to match when parsing strings; default is true. Case sensitivity applies to prefixes, suffixes, the exponent separator, the symbol "NaN", and the infinity symbol. Grouping separators, decimal separators, and padding are always case-sensitive. Currencies are always case-insensitive.This setting is ignored in fast mode. In fast mode, strings are always compared in a case-sensitive way.
- Parameters:
parseCaseSensitive
- true to be case-sensitive when parsing; false to allow any case.- Returns:
- The property bag, for chaining.
-
setParseIntegerOnly
Whether to ignore the fractional part of numbers. For example, parses "123.4" to "123" instead of "123.4".- Parameters:
parseIntegerOnly
- true to parse integers only; false to parse integers with their fraction parts- Returns:
- The property bag, for chaining.
-
setParseMode
Controls certain rules for how strict this parser is when reading strings. SeeDecimalFormatProperties.ParseMode.LENIENT
andDecimalFormatProperties.ParseMode.STRICT
.- Parameters:
parseMode
- EitherDecimalFormatProperties.ParseMode.LENIENT
orDecimalFormatProperties.ParseMode.STRICT
.- Returns:
- The property bag, for chaining.
-
setParseNoExponent
Whether to ignore the exponential part of numbers. For example, parses "123E4" to "123" instead of "1230000".- Parameters:
parseNoExponent
- true to ignore exponents; false to parse them.- Returns:
- The property bag, for chaining.
-
setParseToBigDecimal
Whether to always return a BigDecimal from parse methods. By default, a Long or a BigInteger are returned when possible.- Parameters:
parseToBigDecimal
- true to always return a BigDecimal; false to return a Long or a BigInteger when possible.- Returns:
- The property bag, for chaining.
-
setPluralRules
Sets the PluralRules object to use instead of the default for the locale.- Parameters:
pluralRules
- The object to reference.- Returns:
- The property bag, for chaining.
-
setPositivePrefix
Sets the prefix to prepend to positive numbers. The prefix will be interpreted literally. For example, if you set a positive prefix ofp
, then the number 123 will be formatted as "p123" in the locale en-US.For more information on prefixes and suffixes, see
MutablePatternModifier
.- Parameters:
positivePrefix
- The CharSequence to prepend to positive numbers.- Returns:
- The property bag, for chaining.
- See Also:
-
setPositivePrefixPattern
Sets the prefix to prepend to positive numbers. Locale-specific symbols will be substituted into the string according to Unicode Technical Standard #35 (LDML).For more information on prefixes and suffixes, see
MutablePatternModifier
.- Parameters:
positivePrefixPattern
- The CharSequence to prepend to positive numbers after locale symbol substitutions take place.- Returns:
- The property bag, for chaining.
- See Also:
-
setPositiveSuffix
Sets the suffix to append to positive numbers. The suffix will be interpreted literally. For example, if you set a positive suffix ofp
, then the number 123 will be formatted as "123p" in the locale en-US.For more information on prefixes and suffixes, see
MutablePatternModifier
.- Parameters:
positiveSuffix
- The CharSequence to append to positive numbers.- Returns:
- The property bag, for chaining.
- See Also:
-
setPositiveSuffixPattern
Sets the suffix to append to positive numbers. Locale-specific symbols will be substituted into the string according to Unicode Technical Standard #35 (LDML).For more information on prefixes and suffixes, see
MutablePatternModifier
.- Parameters:
positiveSuffixPattern
- The CharSequence to append to positive numbers after locale symbol substitutions take place.- Returns:
- The property bag, for chaining.
- See Also:
-
setRoundingIncrement
Sets the increment to which to round numbers. For example, with a rounding interval of 0.05, the number 11.17 would be formatted as "11.15" in locale en-US with the default rounding mode.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.
- Parameters:
roundingIncrement
- The interval to which to round.- Returns:
- The property bag, for chaining.
-
setRoundingMode
Sets the rounding mode, which determines under which conditions extra decimal places are rounded either up or down. SeeRoundingMode
for details on the choices of rounding mode. The default if not set explicitly isRoundingMode.HALF_EVEN
.This setting is ignored if
setMathContext(java.math.MathContext)
is used.- Parameters:
roundingMode
- The rounding mode to use when rounding is required.- Returns:
- The property bag, for chaining.
- See Also:
-
setSecondaryGroupingSize
Sets the number of digits between grouping separators higher than the least-significant grouping separator. For example, the locale hi uses a primary grouping size of 3 and a secondary grouping size of 2, so the number 1234567 would be formatted as "12,34,567".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.###".
- Parameters:
secondaryGroupingSize
- The secondary grouping size.- Returns:
- The property bag, for chaining.
-
setSignAlwaysShown
Sets whether to always display of a plus sign on positive numbers.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.
- Parameters:
signAlwaysShown
- Whether positive numbers should display a plus sign.- Returns:
- The property bag, for chaining.
-
toString
-
toStringBare
Appends a string containing properties that differ from the default, but without being surrounded by <Properties>. -
writeObject
Custom serialization: save fields along with their name, so that fields can be easily added in the future in any order. Only save fields that differ from their default value.- Throws:
IOException
-
writeObjectImpl
- Throws:
IOException
-