Package com.redwood.scheduler.api.model
Class BigDecimalFormat
- java.lang.Object
-
- com.redwood.scheduler.api.model.BigDecimalFormat
-
public class BigDecimalFormat extends Object
Formatting and parsing for BigDecimals with a flexible syntax specified entirely by the format string.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BigDecimalFormat.BigDecimalFormatException
A formatting or parsing exception.
-
Field Summary
Fields Modifier and Type Field Description static String
VALID_NAMES
-
Constructor Summary
Constructors Constructor Description BigDecimalFormat(String newFormat)
Format controls for numbers, based onDecimalFormat
, with the ability to specify the locale and formatting information inside the format string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
check(Consumer<Exception> failureHandler)
Check all common cases.String
format(BigDecimal input)
BigDecimal
parse(String input)
-
-
-
Field Detail
-
VALID_NAMES
public static final String VALID_NAMES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BigDecimalFormat
public BigDecimalFormat(String newFormat) throws BigDecimalFormat.BigDecimalFormatException
Format controls for numbers, based onDecimalFormat
, 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 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
- 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 theDecimalFormatSymbols
, supported attributes are below. - The last segment is treated as a
DecimalFormat
.
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 ofDecimalFormatSymbols
(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
-
-
Method Detail
-
parse
public BigDecimal parse(String input) throws BigDecimalFormat.BigDecimalFormatException
-
format
public String format(BigDecimal input) throws BigDecimalFormat.BigDecimalFormatException
-
-