Menu

#146 @CSVDate fails

v1.0 (example)
closed-invalid
None
5
2017-07-05
2017-06-18
No

Model
@CsvBindByPosition(position = 14)
@CsvDate(value = "yyyy-MM-dd HH:mm:ss.S")
Date product_last_update;

In method    private void processProperty(MappingStrategy<T> mapper, String[] line, T bean, int col)

the Object obj returned from convertvalue is a String and not a Date throwing a Illegal argument when invoking prop.getWriteMethod().invoke(bean, obj);
as Obj is String and not Date.

Discussion

  • Bernard Guillot

    Bernard Guillot - 2017-06-18

    Exception received on version 3.9 is
    Caused by: java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.opencsv.bean.CsvToBean.processProperty(CsvToBean.java:290)
    at com.opencsv.bean.CsvToBean.processLine(CsvToBean.java:277)
    at com.opencsv.bean.CsvToBean.processLine(CsvToBean.java:244)
    at com.opencsv.bean.CsvToBean.parse(CsvToBean.java:221)

     
  • Andrew Rucker Jones

    This looks like a mapping problem. processProperty() is only called when opencsv doesn't recognize the annotations. I can't imagine why the annotations would fail to be recognized. In order to help you, you will have to provide me with more information, like your code and your data.

     
  • Andrew Rucker Jones

    • assigned_to: Andrew Rucker Jones
     
  • Andrew Rucker Jones

    I intend on closing this ticket in a couple of days unless I get more information.

     
  • Andrew Rucker Jones

    • status: open --> closed-invalid
     

Log in to post a comment.