|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.univocity.parsers.conversions.ObjectConversion<T>
com.univocity.parsers.conversions.NumericConversion<BigDecimal>
com.univocity.parsers.conversions.FormattedBigDecimalConversion
public class FormattedBigDecimalConversion
Converts formatted Strings to instances of BigDecimal
and vice versa.
This class supports multiple numeric formats. For example, you can define conversions from numbers represented by different Strings such as "1,000,000.00 and $5.00".
The reverse conversion from a BigDecimal to String (in revert(BigDecimal)
will return a formatted String using the pattern provided in this class constructor
The numeric patterns must follows the pattern rules of DecimalFormat
DecimalFormat
Constructor Summary | |
---|---|
FormattedBigDecimalConversion(BigDecimal valueIfStringIsNull,
String valueIfObjectIsNull,
String... numericFormats)
Defines a conversion from String to BigDecimal using a sequence of acceptable numeric patterns. |
|
FormattedBigDecimalConversion(String... numericFormats)
Defines a conversion from String to BigDecimal using a sequence of acceptable numeric patterns. |
Method Summary | |
---|---|
protected void |
configureFormatter(DecimalFormat formatter)
Configures the Decimal format instance created by the parent class to parse BigDecimals. |
Methods inherited from class com.univocity.parsers.conversions.NumericConversion |
---|
fromString, revert |
Methods inherited from class com.univocity.parsers.conversions.ObjectConversion |
---|
execute, getValueIfObjectIsNull, getValueIfStringIsNull, setValueIfObjectIsNull, setValueIfStringIsNull |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FormattedBigDecimalConversion(BigDecimal valueIfStringIsNull, String valueIfObjectIsNull, String... numericFormats)
BigDecimal
using a sequence of acceptable numeric patterns.
This constructor assumes the output of a conversion should be null when input is null
valueIfStringIsNull
- default BigDecimal to be returned when the input String is null. Used when ObjectConversion.execute(String)
is invoked.valueIfObjectIsNull
- default String value to be returned when a BigDecimal input is null. Used when revert(BigDecimal)
is invoked.numericFormats
- list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in revert(BigDecimal)
.public FormattedBigDecimalConversion(String... numericFormats)
BigDecimal
using a sequence of acceptable numeric patterns.
This constructor assumes the output of a conversion should be null when input is null
numericFormats
- list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in revert(BigDecimal)
.Method Detail |
---|
protected void configureFormatter(DecimalFormat formatter)
configureFormatter
in class NumericConversion<BigDecimal>
formatter
- a DecimalFormat instance initialized with one of the patterns provided in the constructor of this class.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |