Reading time values from spreadsheet using poi api

Ronny1971

New Member
I am trying to read a date column and a time column from a spreadsheet. I am able to retireve the date column from the sheet, but not the time column. For example, my sheet will have rows of the form: date time11/2/2012 12:15:01I have the following code to get the date column: \[code\]while(cellIterator.hasNext()) { HSSFCell cell = (HSSFCell)cellIterator.next(); switch(cell.getCellType()){ case HSSFCell.CELL_TYPE_NUMERIC: HSSFCellStyle style = cell.getCellStyle(); if (HSSFDateUtil.isCellDateFormatted(cell)) { d = (Date)getDateValue(cell); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); System.out.println(dateFormat.format(d)); } } } protected static Object getDateValue(HSSFCell cellDate) { double numericDateValue = http://stackoverflow.com/questions/15710888/cellDate.getNumericCellValue(); Date date = HSSFDateUtil.getJavaDate(numericDateValue); return date;}\[/code\]As you can see I use \[quote\] HSSFDateUtil.isCellDateFormatted(cell)\[/quote\]to check if the cell has date value in it. I want to know if i can check if cell has time value using any function. The excel sheet is coming from an external source. So,i will not be able to make any modifications to the format of it. Right now, i get the correct date values for date columns. But, for time columns, i am getting \[quote\] 12/31/1899\[/quote\]as result for all rows
 
Back
Top