Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HSSF POI : How to know if data in cell is of Type Date?

Currently i have my code as

bean.setREPO_DATE(row.getCell(16).getDateCellValue());

it works fine if cell is formatted as date in excel.

However it also converts some integer or long like 1234 or 5699 to date. I know the reason behind this too.

However i want to apply a check before executing above line. Something like this

if(row.getCell(16).isOfDateFormat){
bean.setREPO_DATE(row.getCell(16).getDateCellValue());
} 

Please Guide me..

Thanks in Advance !

like image 739
Abhishek Singh Avatar asked Aug 19 '13 06:08

Abhishek Singh


1 Answers

Try this,

use import org.apache.poi.ss.usermodel.DateUtil;

if(DateUtil.isCellDateFormatted(cell))
   {
       cell.getDateCellValue();
   }
like image 196
newuser Avatar answered Sep 28 '22 13:09

newuser