Reputation: 6656
I have a cell with the 1:20
time value (1:20:00)
. How can I read it by apache poi 3.9?
My code is checking two cell types, and when it reads the time value, it goes to the CELL_TYPE_NUMERIC
, and the 1:20
will be 0
. How could I read the exactly 1:20
? Thank you!
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:
cellValue = String.valueOf((int) (cell.getNumericCellValue()));
break;
case HSSFCell.CELL_TYPE_STRING:
cellValue = cell.getStringCellValue();
break;
}
Upvotes: 1
Views: 2475
Reputation: 6656
I did it!!
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:
if(DateUtil.isCellDateFormatted(cell)) {
cellValue = new DataFormatter().formatCellValue(cell);
} else {
cellValue = String.valueOf((int) (cell.getNumericCellValue()));
}
break;
case HSSFCell.CELL_TYPE_STRING:
cellValue = cell.getStringCellValue();
break;
}
Upvotes: 1