I am trying to create an Excel Work sheet using POI api in Java. In that Excel Work Sheet I want to have a cell with TIME alone. By setting this we can include the cell in summa
You can use DateUtil.convertTime(String time) method where time is like "HH:MM" or "HH:MM:SS". This method will give you a double value which you can set as value in your cell (cell.setCellValue(double value)).
But convertTime method doesn't work with hours > 23. If you need this opportunity, you can write your own convertTime method, somthing like this:
double convertTime(long hours, long minutes, long seconds) {
double totalSeconds = seconds + (minutes + (hours) * 60) * 60;
return totalSeconds / (SECONDS_PER_DAY);
}
SECONDS_PER_DAY = 60 * 60 * 24. You can simply take it from DateUtil class.
Remember, you must define your cell format properly that excel can put in hours more than 23.