Using the bean function to map the fields, I was hoping there would be some example on how to work with dates.
My csv file date looks like this: 12-Jan-2009 00:00:00
My bean class has a field java.sql.Timestamp
When I do the List<App_request_extract> list = csv.parse(strat, reader); I get an error that it could not map the value. I removed the date from the extract and the bean, then the csv.parse worked beautifully.
I am probably missing something obvious. Do I have to override a method or set something in the Mapping Strategy?
CSVReader reader = new CSVReader(new BufferedReader(new FileReader("extract.csv")), '|', CSVWriter.NO_QUOTE_CHARACTER);
HeaderColumnNameMappingStrategy<App_request_extract> strat = new HeaderColumnNameMappingStrategy<App_request_extract>();
strat.setType(App_request_extract.class);
CsvToBean<App_request_extract> csv = new CsvToBean<App_request_extract>();
List<App_request_extract> list = csv.parse(strat, reader);
Could you please attach the following.
1. A small csv file with one or two records with the data that causes the issue.
2. app_request_extract.java
3. A small runnable app that recreates the issue
Given the code you put in the issue I can recreate #3 easily enough but 1 and 2 would REALLY be helpful.
Sure.
Attached is a runnable class that includes app_request_extract
Attached is a small csv file with sample data
runnable class
csv test data
Added Feature request 2911984 which is a more generic version of 2892681 that will hopefully take care of this when implemented.