Please help me how to read an xls
which file using Apache POI having cell value in the format HH:MM:SS
.
I am able to read cell value if time stamp in xls
cell less than or equal 24 hours. (e.g. 23:30:30
).
Now my requirement is to read the same cell value even greater than 24 hours (e.g. 55:34:34
) and store it in the database.
Dates and times in Excel are stored as floating point numbers. Dates are days since 1900 (a date of 1 is 01/01/1900), and times are fractions of a day (so 0.5 is 12 hours).
Depending on what format you need the value to be in before you put it in a database, then you might just want to take the numeric value and multiple by 24 to get the hours and fractional hours, eg:
double time = cell.getNumericCellValue() * 24;
int hours = (int)time;
int minutes = (time - hours) * 60;
Alternately, if you want a string, then the DataFormatter class will happily format a value of 1.5 as HH:MM to 36:00