-1

I am getting an date in an cell in excel sheet having extension .xls that i am reading through POI in java for HSSF sheet i have the below cross check that is working fine

if (HSSFDateUtil.isCellDateFormatted(row.getCell(0))) {
}

Now please advise i am getting few sheets having extension .xlsx please advise how can i implement the above method to read date value from acell in XSSF sheet

tgfghfh hghg
  • 39
  • 1
  • 7
  • @trashgod No this is not duplicate of this , well please advise how can i get equivalent method for xssf sheet as I have for hssf sheet – tgfghfh hghg Dec 05 '15 at 14:30
  • It is. This helpful [answer](http://stackoverflow.com/a/34108544/230513) summarizes the correct approach, shown [here](http://stackoverflow.com/a/3562214/230513) in context. – trashgod Dec 05 '15 at 18:20

1 Answers1

2

As explained in the Apache POI docs (who ever heard of reading the docs?), you need to change from HSSFDateUtil to DateUtil

So your old code

import org.apache.poi.hssf.usermodel.HSSFDateUtil;

....

if (HSSFDateUtil.isCellDateFormatted(row.getCell(0))) {

Just becomes

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

....

if (DateUtil.isCellDateFormatted(row.getCell(0))) {

And you're done!

Gagravarr
  • 47,320
  • 10
  • 111
  • 156