Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
Numeric type can contain a Date instead of a number, check
added for Date and return the time in millis if a Date is found.
  • Loading branch information
mdeinum authored and mminella committed Mar 13, 2015
1 parent b90a132 commit 6e6f2dc
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
package org.springframework.batch.item.excel.poi;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.springframework.batch.item.excel.Sheet;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

Expand Down Expand Up @@ -82,7 +84,12 @@ public String[] getRow(final int rowNumber) {
Cell cell = row.getCell(i);
switch (cell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
cells.add(String.valueOf(cell.getNumericCellValue()));
if (DateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue();
cells.add(String.valueOf(date.getTime()));
} else {
cells.add(String.valueOf(cell.getNumericCellValue()));
}
break;
case Cell.CELL_TYPE_BOOLEAN:
cells.add(String.valueOf(cell.getBooleanCellValue()));
Expand Down

0 comments on commit 6e6f2dc

Please sign in to comment.