excel解析时间24格式 解决方案

//如excel 中2013-01-04 18:30:12 PM    解析后的这列cell 传入此方法  将返回  2013-01-04 18:30:12

public static String FormateTime(Cell formatecell) {
    try {
        java.util.Date mydate = null;
        DateCell datecll = (DateCell) formatecell;
        mydate = datecll.getDate();
        long time = (mydate.getTime() / 1000) - 60 * 60 * 8;
        mydate.setTime(time * 1000);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(mydate);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

posted on 2013-02-15 11:32  蜜雪薇琪  阅读(264)  评论(0编辑  收藏  举报