public class FmtNumber extends CellProcessorAdaptor implements DoubleCellProcessor, LongCellProcessor
DecimalFormat
class and the default locale. This is
useful, when you need to show numbers with a specific number of digits.
Please be aware that the constructors that use DecimalFormat are not thread-safe, so it is generally better to use the constructors that accept a date format String.
In the format string, the following characters are defined as :
0 - means Digit # - means Digit, zero shows as absent (works only as zero padding on the right hand side of the number) . - means Decimal separator or monetary decimal separator - - means Minus sign , - means Grouping separator
ParseDouble
or ParseBigDecimal
processor.next
Constructor and Description |
---|
FmtNumber(DecimalFormat formatter)
Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied
decimal format.
|
FmtNumber(DecimalFormat formatter,
StringCellProcessor next)
Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied
decimal format, then calls the next processor in the chain.
|
FmtNumber(String decimalFormat)
Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied
decimal format String.
|
FmtNumber(String decimalFormat,
StringCellProcessor next)
Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied
decimal format String, then calls the next processor in the chain.
|
Modifier and Type | Method and Description |
---|---|
Object |
execute(Object value,
CsvContext context)
This method is invoked by the framework when the processor needs to process data or check constraints.
|
toString, validateInputNotNull
public FmtNumber(String decimalFormat)
decimalFormat
- the decimal format String (see DecimalFormat
)NullPointerException
- if decimalFormat is nullpublic FmtNumber(String decimalFormat, StringCellProcessor next)
decimalFormat
- the decimal format String (see DecimalFormat
)next
- the next processor in the chainNullPointerException
- if decimalFormat or next is nullpublic FmtNumber(DecimalFormat formatter)
formatter
- the DecimalFormatNullPointerException
- if formatter is nullpublic FmtNumber(DecimalFormat formatter, StringCellProcessor next)
formatter
- the DecimalFormatnext
- the next processor in the chainNullPointerException
- if formatter or next is nullpublic Object execute(Object value, CsvContext context)
execute
in interface CellProcessor
value
- the value to be processedcontext
- the CSV contextSuperCsvCellProcessorException
- if value is null or not a Number, or if an invalid decimalFormat String was suppliedCopyright © 2007–2015 Super CSV. All rights reserved.