/**
*@description: 时间转字符串
*@Param
*@return
*@author sunhao
*@date 2021-04-30 11:01
*/
public static String dateToString(Cell cell) {
short format = cell.getCellStyle().getDataFormat();
Date dateCellValue = cell.getDateCellValue();
String format1 ="";
SimpleDateFormat sdf = null;
if(format == 14){
sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(dateCellValue);
}
if (format == 20){
sdf = new SimpleDateFormat("HH:mm");
return sdf.format(dateCellValue);
}
if (format == 21){
sdf = new SimpleDateFormat("HH:mm:ss");
return sdf.format(dateCellValue);
}
if (format == 31 ){
sdf = new SimpleDateFormat("yyyy年MM月dd日");
return sdf.format(dateCellValue);
}
if (format == 32){
sdf = new SimpleDateFormat("HH时mm分");
return sdf.format(dateCellValue);
}
if (format == 33){
sdf = new SimpleDateFormat("HH时mm分mm秒");
return sdf.format(dateCellValue);
}
if (format == 57){
sdf = new SimpleDateFormat("yyyy年MM月");
return sdf.format(dateCellValue);
}
if (format == 58){
sdf = new SimpleDateFormat("MM月dd日");
return sdf.format(dateCellValue);
}
if (format == 176){
sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(dateCellValue);
}
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(dateCellValue);
}