Package com.opencsv.bean
Annotation Type CsvNumber
-
@Documented @Retention(RUNTIME) @Target(FIELD) public @interface CsvNumber
This annotation indicates that the destination field is a number that is specially formatted. Numbers that have no more formatting than that which comes with a locale (or the default locale) do not require this annotation. If a locale is specified in the attendant CSV binding annotation (CsvBindByName
,CsvBindByPosition
, etc.), it is used for the conversion. The following types are supported:- byte /
Byte
- double /
Double
- float /
Float
- int /
Integer
- long /
Long
- short /
Short
BigDecimal
BigInteger
- Since:
- 4.2
- Author:
- Andrew Rucker Jones
- byte /
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.String
value
A decimal format string.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.String
writeFormat
A number format string.boolean
writeFormatEqualsReadFormat
Whether or not the same format string is used for writing as for reading.
-
-
-
Element Detail
-
value
java.lang.String value
A decimal format string. This must be a localized pattern understood byDecimalFormat
. The locale is gleaned from one of the other CSV-related annotations if present there, or failing that, is the default locale for the JVM. If your code might run under different locales, you are strongly encouraged to always specify a locale for conversions, otherwise your code will behave unpredictably.- Returns:
- The format string for parsing input
-
-
-
writeFormatEqualsReadFormat
boolean writeFormatEqualsReadFormat
Whether or not the same format string is used for writing as for reading. If this is true,value()
is used for both reading and writing andwriteFormat()
is ignored.- Returns:
- Whether the read format is used for writing as well
- Since:
- 5.0
- Default:
- true
-
-
-
writeFormat
java.lang.String writeFormat
A number format string. The default value is blank and only exists to make sure the parameter is optional.- Returns:
- The format string for formatting output
- Since:
- 5.0
- See Also:
value()
,writeFormatEqualsReadFormat()
- Default:
- ""
-
-