Excel中有各式各样的日期类型,如何用java取得你想要的类型呢?
(jxl)代码如下:
Sheet[] sheets = book.getSheets();
Sheet sheet = sheets[0];
String birthday = sheet.getCell(1, 1).getContents().trim(); Cell c = sheet.getCell(1, 1);
CellType ct = c.getType();
if(ct==CellType.DATE)
{
DateCell dc = (DateCell)c;
Date dd = dc.getDate();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
birthday = df.format(dd);
}
(jxl)代码如下:
Sheet[] sheets = book.getSheets();
Sheet sheet = sheets[0];
String birthday = sheet.getCell(1, 1).getContents().trim(); Cell c = sheet.getCell(1, 1);
CellType ct = c.getType();
if(ct==CellType.DATE)
{
DateCell dc = (DateCell)c;
Date dd = dc.getDate();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
birthday = df.format(dd);
}