获取Excel单元格存储日期格式数据

获取Excel单元格存储日期格式数据

在使用java获取Excel单元格中数据时,如果单元格数据为日期格式,直接使用cell.getValue()获取单元格的值,获取到的值为一个数字乱码,可以使用以下方法进行数据格式的转换后,再进行数据的获取。

public String dealCellDate(XssfCell cell){
    
    
    Date date = cell.getDateCellValue();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    String dateFormat = sdf.format(date);
	return dateFormat;
}

猜你喜欢

转载自blog.csdn.net/origin_cx/article/details/109367601
今日推荐