Top Description Constructors Methods
com.univocity.parsers.conversions

public Class FormattedBigDecimalConversion

extends NumericConversion<BigDecimal>
Class Inheritance
Imports
java.math.*, java.text.*

Converts formatted Strings to instances of java.math.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 follow the pattern rules of java.text.DecimalFormat

Author
Univocity Software Pty Ltd - [email protected]
See Also
java.text.DecimalFormat

Constructor Summary

AccessConstructor and Description
public
FormattedBigDecimalConversion(BigDecimal
default BigDecimal to be returned when the input String is null. Used when ObjectConversion#execute(String) is invoked.
valueIfStringIsNull
,
String
default String value to be returned when a BigDecimal input is null. Used when revert(BigDecimal) is invoked.
valueIfObjectIsNull
,
String...
list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in revert(BigDecimal).
numericFormats
)

Defines a conversion from String to java.math.BigDecimal using a sequence of acceptable numeric patterns.

public
FormattedBigDecimalConversion(BigDecimal
default BigDecimal to be returned when the input String is null. Used when ObjectConversion#execute(String) is invoked.
valueIfStringIsNull
,
String
default String value to be returned when a BigDecimal input is null. Used when NumericConversion#revert(Number) is invoked.
valueIfObjectIsNull
)

Defines a conversion from String to java.math.BigDecimal using a sequence of acceptable numeric patterns.

public
FormattedBigDecimalConversion(String...
list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in NumericConversion#revert(Number).
numericFormats
)

Defines a conversion from String to java.math.BigDecimal using a sequence of acceptable numeric patterns.

public
FormattedBigDecimalConversion(DecimalFormat...
list formatters of acceptable numeric patterns. The first formatter in this sequence will be used to convert a BigDecimal into a String in NumericConversion#revert(Number).
numericFormatters
)

Defines a conversion from String tojava.math.BigDecimal using a sequence of acceptable numeric patterns.

public
FormattedBigDecimalConversion()

Defines a conversion from String to java.math.BigDecimal using a sequence of acceptable numeric patterns.

Method Summary

Modifier and TypeMethod and Description
protected void
configureFormatter(DecimalFormat
a DecimalFormat instance initialized with one of the patterns provided in the constructor of this class.
formatter
)

Implements abstract com.univocity.parsers.conversions.NumericConversion.configureFormatter.

Configures the Decimal format instance created by the parent class to parse BigDecimals.
Inherited from com.univocity.parsers.conversions.NumericConversion:
addFormatfromStringgetFormatterObjectsgetNumberTyperevertsetNumberType

Constructor Detail

FormattedBigDecimalConversionback to summary
public FormattedBigDecimalConversion(BigDecimal valueIfStringIsNull, String valueIfObjectIsNull, String... numericFormats)

Defines a conversion from String to java.math.BigDecimal using a sequence of acceptable numeric patterns. This constructor assumes the output of a conversion should be null when input is null

Parameters
valueIfStringIsNull:BigDecimal

default BigDecimal to be returned when the input String is null. Used when ObjectConversion#execute(String) is invoked.

valueIfObjectIsNull:String

default String value to be returned when a BigDecimal input is null. Used when revert(BigDecimal) is invoked.

numericFormats:String[]

list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in revert(BigDecimal).

FormattedBigDecimalConversionback to summary
public FormattedBigDecimalConversion(BigDecimal valueIfStringIsNull, String valueIfObjectIsNull)

Defines a conversion from String to java.math.BigDecimal using a sequence of acceptable numeric patterns. The patterns must be added to this conversion class through the addFormat(String, String...) method.

Parameters
valueIfStringIsNull:BigDecimal

default BigDecimal to be returned when the input String is null. Used when ObjectConversion#execute(String) is invoked.

valueIfObjectIsNull:String

default String value to be returned when a BigDecimal input is null. Used when NumericConversion#revert(Number) is invoked.

FormattedBigDecimalConversionback to summary
public FormattedBigDecimalConversion(String... numericFormats)

Defines a conversion from String to java.math.BigDecimal using a sequence of acceptable numeric patterns. This constructor assumes the output of a conversion should be null when input is null

Parameters
numericFormats:String[]

list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in NumericConversion#revert(Number).

FormattedBigDecimalConversionback to summary
public FormattedBigDecimalConversion(DecimalFormat... numericFormatters)

Defines a conversion from String tojava.math.BigDecimal using a sequence of acceptable numeric patterns. This constructor assumes the output of a conversion should be null when input is null

Parameters
numericFormatters:DecimalFormat[]

list formatters of acceptable numeric patterns. The first formatter in this sequence will be used to convert a BigDecimal into a String in NumericConversion#revert(Number).

FormattedBigDecimalConversionback to summary
public FormattedBigDecimalConversion()

Defines a conversion from String to java.math.BigDecimal using a sequence of acceptable numeric patterns. The patterns must be added to this conversion class through the addFormat(String, String...) method. This constructor assumes the output of a conversion should be null when input is null

Method Detail

configureFormatterback to summary
protected void configureFormatter(DecimalFormat formatter)

Implements abstract com.univocity.parsers.conversions.NumericConversion.configureFormatter.

Configures the Decimal format instance created by the parent class to parse BigDecimals.

Parameters
formatter:DecimalFormat

Doc from com.univocity.parsers.conversions.NumericConversion.configureFormatter.

a DecimalFormat instance initialized with one of the patterns provided in the constructor of this class.

Annotations
@Override