poi设置日期格式

方法一:

CreationHelper createHelper=wb.getCreationHelper();
CellStyle cellStyle=wb.createCellStyle(); //单元格样式类
cellStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyy-mm-dd hh:mm:ss"));
cell=row.createCell(1);
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle);

 方法二:

cell=row.createCell(2); 
cell.setCellValue(Calendar.getInstance());
cell.setCellStyle(cellStyle);

猜你喜欢

转载自hzxlb910.iteye.com/blog/2353173