public class ConverterNumber extends AbstractCsvConverter
CsvNumber
, that is,
when number inputs and outputs should be formatted.errorLocale, locale, type, writeLocale
Constructor and Description |
---|
ConverterNumber(Class<?> type,
String locale,
String writeLocale,
Locale errorLocale,
String readFormat,
String writeFormat,
RoundingMode roundingMode) |
Modifier and Type | Method and Description |
---|---|
Object |
convertToRead(String value)
Method for converting from a string to the proper data type of the
destination field.
|
String |
convertToWrite(Object value)
Formats the number in question according to the pattern that has been
provided.
|
setErrorLocale, setLocale, setType, setWriteLocale
public ConverterNumber(Class<?> type, String locale, String writeLocale, Locale errorLocale, String readFormat, String writeFormat, RoundingMode roundingMode) throws CsvBadConverterException
type
- The class of the type of the data being processedlocale
- If not null or empty, specifies the locale used for
converting locale-specific data types for readingwriteLocale
- If not null or empty, specifies the locale used for
converting locale-specific data types for writingerrorLocale
- The locale to use for error messagesreadFormat
- The string to use for parsing the number.writeFormat
- The string to use for formatting the number.roundingMode
- The rounding mode used when converting BigDecimal
s.CsvBadConverterException
- If the information given to initialize the converter are inconsistent (e.g.
the annotation CsvNumber
has been applied to a non-Number
type.CsvNumber.value()
public Object convertToRead(String value) throws CsvDataTypeMismatchException
CsvConverter
value
- The string from the selected field of the CSV file. If the
field is marked as required in the annotation, this value is guaranteed
not to be null
, empty or blank according to
StringUtils.isBlank(java.lang.CharSequence)
Object
representing the input data converted
into the proper typeCsvDataTypeMismatchException
- If the input string cannot be converted into
the proper typepublic String convertToWrite(Object value) throws CsvDataTypeMismatchException
convertToWrite
in interface CsvConverter
convertToWrite
in class AbstractCsvConverter
value
- The contents of the field currently being processed from the
bean to be written. Can be null
if the field is not marked as
required.value
is null
CsvDataTypeMismatchException
- This implementation doesn't, but
subclasses do, so it must be declaredCopyright © 2005–2023. All rights reserved.