JAVA 读取excel中的日期是为12小时制的

来源:互联网 发布:iapp轰炸机源码 编辑:程序博客网 时间:2024/04/28 00:10
原因是:引用jxl 时有个pattern类用的是12时制的时间(文件内容 18:05 读出后 6:05
所以...., 要自己写个方法来再次将它读出的时间进行转换。

    /**
     * <概要描述> excle文件中时间类型数据格式转换
     * @param excle文件中时间类型数据
     * @return String
     * @throws 无
     */
    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;
        }
    }

0 0