以下代码可以解决这个问题:
if(cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC
&& cell.getCellStyle().getDataFormat() ==
HSSFDataFormat.getBuiltinFormat("h:mm")){
String sDate = cell.getNumericCellValue()+"";
if(!StringUtil.isEmpty(sDate)){
Date date = HSSFDateUtil.getJavaDate(cell.getNumericCellValue());
return new SimpleDateFormat("h:mm").format(date);
}
return "";
}
其中,单元格的格式属性是custom h:mm