jxl读取excel自定义日期类型

String tempTime = st.getCell(0, k + 1).getContents(); 

long tempTimeLong = Long.valueOf(tempTime).intValue();  //将数字转化成long型 

long ss = (tempTimeLong - 70 * 365 - 17 - 2) * 24 * 3600 * 1000;  //excel的那个数字是距离1900年的天数 
                                                                          //java 是距离1970年天数,但是明明期间只有17个闰年 
                                                                          //我尝试的结果要减19才能正确,原因不明 

Date dss = new Date(ss);                              //用这个数字初始化一个Date 

SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日"); 

String sss = formatter.format(dss);

 

你可能感兴趣的:(Excel)