jxl读取excel文件中的时间类型

来源:互联网 发布:花无涯网络黑白电子版 编辑:程序博客网 时间:2024/06/05 07:21

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);  
  }  

原创粉丝点击