title: apache poi write HH:mm:ss string to Excel Time data type
body: <p>i used apache poi to rewrite a CSV file to Excel, for any string like HH:mm:ss, i need to convert it to the appropriate Excel data type so that user can apply sum() function on that column. i tried different datatype, but when i open the excel file i cannot sum that column the sum always showed as "0:00:00", even though clicking on that column in excel it showed as 'Time' data type,</p>
  
  <p>here is my code:</p>
  
  <pre><code>CreationHelper creationHelper = workbook.getCreationHelper();
  HSSFCellStyle timeStyle = workbook.createCellStyle();          
  timeStyle.setDataFormat(creationHelper.createDataFormat().getFormat("h:mm:ss"));
  cell.setCellValue(column);
  if (isTime(column)) {
    cell.setCellStyle(timeStyle);
  }
  
  private boolean isTime(String value) {
          try {
              dtf.parseDateTime(value);
              return true;
          } catch (IllegalArgumentException e) {
              return false;
          }
      }
  </code></pre>
  
  <p>and here is my excel file
  <a href="https://i.stack.imgur.com/nl4E4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nl4E4.png" alt="enter image description here"></a></p>