1

I am reading an .xlsx file which contain columns like Name, Id , Date(11/28/2017) and few more. I created one .xml file "cancellation.xml" to map my excel cells. After that I am reading the excel file using these lines of codes.

Resource configFile = new FileSystemResource("resource" + File.separator + "excel" + File.separator + "template" +  File.separator +  "cancellation.xml");
            BeanUtilsBean.getInstance().getConvertUtils().register(false, false, 0);
            final XLSReader xlsReader = ReaderBuilder.buildFromXML(configFile.getFile());
            final List<Transaction> transactionList = new ArrayList<>();

            final Map<String, Object> transactionMap = new HashMap<>();
            transactionMap.put("transactionList", transactionList);
            xlsReader.read(multipartFile.getInputStream(), transactionMap);

Everything works fine when I hit the API for the first time and it reads all the columns successfully. But when I hit the API after the first hit it fails to read the columns of excel showing by these error.

2018-03-19 14:05:13.976 WARN 7312 --- [nio-8085-exec-4] o.a.c.b.converters.DateConverter : DateConverter does not support default String to 'Date' conversion. 2018-03-19 14:05:13.976 WARN 7312 --- [nio-8085-exec-4] o.a.c.b.converters.DateConverter : (N.B. Re-configure Converter or use alternative implementation)

Muddassir Rahman
  • 976
  • 1
  • 9
  • 20

1 Answers1

1

What u can try is to register a dateconverter with a pattern or patterns. Here is an example:

DateTimeConverter dateConverter = new DateConverter(null);
dateConverter.setPatterns(new String[]{"MM/dd/yyyy", "yyyy-MM-dd", "dd-MM-yyyy"});
// or just use: dateConverter.setPattern("MM/dd/yyyy")
ConvertUtils.register(dateConverter, Date.class);
Almira
  • 31
  • 3