java HSSFCell 导入获取时间
导入Excel的时候,后台java获取cell时间的时候,转换成了数字,该方法是把数字转换成时间类型的字符串
public static String getCell(HSSFCell cell) { DecimalFormat df = new DecimalFormat("#"); if (cell == null) return ""; switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: if(HSSFDateUtil.isCellDateFormatted(cell)){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); return sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue())).toString(); } return df.format(cell.getNumericCellValue()); case HSSFCell.CELL_TYPE_STRING: System.out.println(cell.getStringCellValue()); return cell.getStringCellValue(); case HSSFCell.CELL_TYPE_FORMULA: return cell.getCellFormula(); case HSSFCell.CELL_TYPE_BLANK: return ""; case HSSFCell.CELL_TYPE_BOOLEAN: return cell.getBooleanCellValue() + ""; case HSSFCell.CELL_TYPE_ERROR: return cell.getErrorCellValue() + ""; } return ""; }