Top Description Methods
com.opencsv.bean

public @Interface CsvDate

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:FIELD
@Repeatable:CsvDates
Imports
java.lang.annotation.*

This annotation indicates that the destination field is an expression of time.

Conversion to the following old-style types is supported:

Conversion to the following java.time.temporal.TemporalAccessor-style types is supported:

This annotation must be used with either com.opencsv.bean.CsvBindByName or com.opencsv.bean.CsvBindByPosition, otherwise it is ignored.

Author
Andrew Rucker Jones
Since
3.8

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The java.time.chrono.Chronology in use
chronology
()

The java.time.chrono.Chronology that should be used for parsing.

public String[]

Returns:

The names of the profiles this configuration is for
profiles
()

A profile can be used to annotate the same field differently for different inputs or outputs.

public String

Returns:

The format string for parsing input
value
()

A date/time format string.

public String

Returns:

The java.time.chrono.Chronology in use
writeChronology
()

The java.time.chrono.Chronology that should be used for formatting.

public boolean

Returns:

Whether the read chronology is used for writing as well
writeChronologyEqualsReadChronology
()

Whether or not the same chronology string is used for writing as for reading.

public String

Returns:

The format string for formatting output
writeFormat
()

A date/time format string.

public boolean

Returns:

Whether the read format is used for writing as well
writeFormatEqualsReadFormat
()

Whether or not the same format string is used for writing as for reading.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

chronologyback to summary
public String chronology()

The java.time.chrono.Chronology that should be used for parsing.

The value must be understood by java.time.chrono.Chronology#of(String). The requisite ID for the desired Chronology can usually be found in the Javadoc for the getId() method of the specific implementation.

This value is only used for java.time.temporal.TemporalAccessor-based fields. It is ignored for old-style dates and times.

The default value specifies the ISO-8601 chronology. If a blank string or empty string is specified, the chronology is taken from the locale.

Returns:String

The java.time.chrono.Chronology in use

Since
5.0
profilesback to summary
public String[] profiles()

A profile can be used to annotate the same field differently for different inputs or outputs.

Perhaps you have multiple input sources, and they all use different header names or positions for the same data. With profiles, you don't have to create different beans with the same fields and different annotations for each input. Simply annotate the same field multiple times and specify the profile when you parse the input.

The same applies to output: if you want to be able to represent the same data in multiple CSV formats (that is, with different headers or orders), annotate the bean fields multiple times with different profiles and specify which profile you want to use on writing.

Results are undefined if profile names are not unique.

If the same configuration applies to multiple profiles, simply list all applicable profile names here. This parameter is an array of strings.

The empty string, which is the default value, specifies the default profile and will be used if no annotation for the specific profile being used can be found, or if no profile is specified.

Returns:String[]

The names of the profiles this configuration is for

Since
5.4
valueback to summary
public String value()

A date/time format string. If this annotation is applied to old-style dates and times, then this must be a string understood by java.text.SimpleDateFormat#SimpleDateFormat(java.lang.String). If it is applied to java.time.temporal.TemporalAccessor-based dates and times, then this must be a string understood by java.time.format.DateTimeFormatter. The default value works for both styles and conforms with ISO 8601. Locale information, if specified, is gleaned from one of the other CSV-related annotations and is used for conversion.

Returns:String

The format string for parsing input

writeChronologyback to summary
public String writeChronology()

The java.time.chrono.Chronology that should be used for formatting.

Returns:String

The java.time.chrono.Chronology in use

Since
5.0
See Also
chronology(), writeChronologyEqualsReadChronology()
writeChronologyEqualsReadChronologyback to summary
public boolean writeChronologyEqualsReadChronology()

Whether or not the same chronology string is used for writing as for reading. If this is true, chronology() is used for both reading and writing and writeChronology() is ignored.

Returns:boolean

Whether the read chronology is used for writing as well

Since
5.0
writeFormatback to summary
public String writeFormat()

A date/time format string.

Returns:String

The format string for formatting output

Since
5.0
See Also
value(), writeFormatEqualsReadFormat()
writeFormatEqualsReadFormatback to summary
public 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 and writeFormat() is ignored.

Returns:boolean

Whether the read format is used for writing as well

Since
5.0