当我将 xls/xlsx 转换为 csv 时,该 csv 文件中的日期将是 Fri Nov 11 00:00:00 IST 1988。但我需要 yyyy-mm-dd 格式。我可以在以下代码中做什么:[代码]
row = (HSSFRow) rowIterator.next();
// For each row, iterate through each columns
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
cell = (HSSFCell) cellIterator.next();
if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
{
if(HSSFDateUtil.isCellDateFormatted(cell))
{
data.append(cell.getDateCellValue() + "|");
}else
data.append(cell.getNumericCellValue() + "|");
}else if(cell.getCellType() == Cell.CELL_TYPE_BOOLEAN)
{
data.append(cell.getBooleanCellValue() + "|");
} else if(cell.getCellType() == Cell.CELL_TYPE_STRING)
{
data.append(cell.getStringCellValue() + "|");
}
else if(cell.getCellType() == Cell.CELL_TYPE_BLANK)
{
data.append("" + "|");
}
else
{
data.append(cell + ",");
}
}data.append("\r\n");