jxl导入excel文件,时间格式yyyy-MM-dd,可是读取过来之后变为yy-MM-dd(好像有时候会变为dd/MM/yyyy格式,不知道为什么),网上查找,找到以下解决方法:
Cell cellObject = st.getCell(0,0);
if(cellObject.getType() == CellType.DATE)
{
DateCell cellValue = (DateCell)cellObject;
Date dt = cellValue.getDate();
SimpleDateFormat formatter = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
String sd = formatter.format(dt);
System.out.println(sd);
}
jxl Excel 时间格式处理
本文介绍使用jxl库读取Excel文件时遇到的时间格式问题及解决方案。针对从Excel读取日期时出现的格式变化,提供了一段示例代码来说明如何通过SimpleDateFormat将日期格式统一为yy-MM-dd HH:mm:ss。
1229

被折叠的 条评论
为什么被折叠?



