ferronrsmith / jcsv

Automatically exported from code.google.com/p/jcsv
0 stars 0 forks source link

Add ability to change DataFormat for DateProcessor #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Now it is impossible to change DateFormat in DateProcessor.

ValueProcessorProvider creates DateProcessor uses constructor with DateFormat 
argument:
registerValueProcessor(Date.class, new 
DateProcessor(DateFormat.getDateInstance()));

It will be usable to have ability to set DateFormat for java.util.Date format?

Original issue reported on code.google.com by guram.sa...@gmail.com on 20 Aug 2012 at 9:14

GoogleCodeExporter commented 9 years ago
Remark for last line, it is not question, it is statement:
"It will be usable to have ability to set DateFormat for java.util.Date format."

Original comment by guram.sa...@gmail.com on 20 Aug 2012 at 9:32

GoogleCodeExporter commented 9 years ago
Seems like it is possible to remove DateProcessor added by default in 
constructor of ValueProcessorProvider.
Then added new DateProcessor with specified DateFormat as argument can be used.

Original comment by guram.sa...@gmail.com on 20 Aug 2012 at 9:58

GoogleCodeExporter commented 9 years ago
Yes, you are right. You can register your own Date value processor, as you said:

ValueProcessorProvider vpp = new ValueProcessorProvider();
vpp.removeValueProcessor(Date.class);
vpp.registerValueProcessor(Date.class, new DateProcessor(yourDateFormat));
[...]
CSVReader<Person> csvReader = new CSVReaderBuilder<Person>(csvFile).entryParser(
        new AnnotationEntryParser<Person>(Person.class, vpp)).build();

Original comment by skiron...@gmail.com on 22 Aug 2012 at 6:17

GoogleCodeExporter commented 9 years ago
Solution in comment 3.

Original comment by skiron...@gmail.com on 22 Aug 2012 at 6:19