excel2003导入时数据列为日期时,需要验证单元格是否为日期,如果是日期格式就按照日期格式读取数据,默认为格林尼治标准时间,北京为东八区,需要减去8个小时为北京时间。例如:
if (cell.getType() == CellType.DATE)
{
DateCell datec11 = (DateCell) cell;
strcc11 = datec11.getDate();
long time = (strcc11.getTime() / 1000) - 60 * 60 * 8;
strcc11.setTime(time * 1000);
String result ="";
result =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(strcc11);
}
if (cell.getType() == CellType.DATE)
{
DateCell datec11 = (DateCell) cell;
strcc11 = datec11.getDate();
long time = (strcc11.getTime() / 1000) - 60 * 60 * 8;
strcc11.setTime(time * 1000);
String result ="";
result =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(strcc11);
}