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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章