Class BigDecimalFormat


  • public class BigDecimalFormat
    extends Object
    Formatting and parsing for BigDecimals with a flexible syntax specified entirely by the format string.
    • Constructor Detail

      • BigDecimalFormat

        public BigDecimalFormat​(String newFormat)
                         throws BigDecimalFormat.BigDecimalFormatException
        Format controls for numbers, based on DecimalFormat, with the ability to specify the locale and formatting information inside the format string. If the string does not start with | then auto-detection is used:
        • If only one of ',' or '.' is found, then it is treated as the decimal separator.
        • If both of ',' and '.' is found, then the first one is the thousands (grouping) separator, and the second is the decimal separator.
        If the string starts with | then manual mode is used. The string is split into segments, the literal '\007c' is converted to | and the string is interpreted:
        • If there is exactly one segment, it must be |Locale=name where name is a locale
        • If there is more than one segment then the string is interpreted as below
        For more than one segment, interpretation proceeds as follows:
        • The locale is set to Locale.US
        • If a segment contains an = then it is split into a name and a value, and these are used to control the DecimalFormatSymbols used. The name is an attribute of the DecimalFormatSymbols, supported attributes are below.
        • The last segment is treated as a DecimalFormat.
        If the last segment is not a DecimalFormat an exception will be thrown. If any of the prior segments is not in name=value format, an exception will be thrown. Supported attributes of DecimalFormatSymbols (case insensitive):
        • Locale - Sets the base locale. The default is Locale.US. THIS CLEARS ALL OTHER SETTINGS
        • CurrencySymbol - Sets the currency symbol for the currency of these DecimalFormatSymbols in their locale.
        • DecimalSeparator - Sets the character used for decimal sign.
        • Digit - Sets the character used for a digit in a pattern.
        • ExponentSeparator - Sets the string used to separate the mantissa from the exponent.
        • GroupingSeparator - Sets the character used for thousands separator.
        • Infinity - Sets the string used to represent infinity.
        • InternationalCurrencySymbol - Sets the ISO 4217 currency code of the currency of these DecimalFormatSymbols.
        • MinusSign - Sets the character used to represent minus sign.
        • MonetaryDecimalSeparator - Sets the monetary decimal separator.
        • NaN - Sets the string used to represent "not a number".
        • PatternSeparator - Sets the character used to separate positive and negative subpatterns in a pattern.
        • Percent - Sets the character used for percent sign.
        • PerMill - Sets the character used for per mille sign.
        • ZeroDigit - Sets the character used for zero.
        Parameters:
        newFormat - the format to use for parsing or formatting, as specified above.
        Throws:
        BigDecimalFormat.BigDecimalFormatException - if the format cannot be parsed