arnaudroger / SimpleFlatMapper

Fast and Easy mapping from database and csv to POJO. A java micro ORM, lightweight alternative to iBatis and Hibernate. Fast Csv Parser and Csv Mapper
http://simpleflatmapper.org
MIT License
437 stars 76 forks source link

ErrorCollectingMapper doesn't use the specified defaultDateFormat #657

Closed saiar closed 5 years ago

saiar commented 5 years ago

Hi,

While going through the code I found that there is something called as ErrorCollectingMapper in CsvMapperFactory.java.

I find that this behaves differently when compared to the standard mapper that we get by calling CsvMapperFactory.newMapper(...) when it comes to LocalDate. While this mapper seems to take the CsvMapperFactory.defaultDateFormat(...) into consideration while parsing dates, the ErrorCollectingMapper doesn't use it and relies on the default defined within the factory, which happens to be ""yyyy-MM-dd HH:mm:ss".

CsvMapperFactory .newInstance() .defaultDateFormat("yyyy-MM-dd") .newMapper(MyObject.class); works fine, but: CsvMapperFactory .newInstance() .defaultDateFormat("yyyy-MM-dd") .newErrorCollectingMapper(MyObject.class); doesn't.

I found that there is a related issue here.

I was able to use the fix suggested in that thread, which was to use it as follows:

CsvMapperFactory .newInstance() .addColumnProperty("scheduled_date", new DateFormatProperty("yyyy-MM-dd")) .newErrorCollectingMapper(MyObject.class);

arnaudroger commented 5 years ago

Thanks for the report will have a look

saiar commented 5 years ago

Sure. Thanks!

On Wed, Jun 5, 2019 at 2:11 AM Arnaud Roger notifications@github.com wrote:

Thanks for the report will have a look

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arnaudroger/SimpleFlatMapper/issues/657?email_source=notifications&email_token=AEH655ZR63CHVZFCBPM3MODPY3HPLA5CNFSM4HS7EOW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW5Z7OA#issuecomment-498835384, or mute the thread https://github.com/notifications/unsubscribe-auth/AEH6552K4ZQR7LA64YFRX23PY3HPLANCNFSM4HS7EOWQ .