poi cell日期判断 源代码注释

来源:互联网 发布:永宏plc-fbe编程软件 编辑:程序博客网 时间:2024/06/10 10:26
   /**     *  Check if a cell contains a date     *  Since dates are stored internally in Excel as double values     *  we infer it is a date if it is formatted as such.     *  @see #isADateFormat(int, String)     *  @see #isInternalDateFormat(int)    由于日期在Excel内是以double值存储的,所以一个cell如果是这种格式,我们可以推断它是一个日期。 */    public static boolean isCellDateFormatted(Cell cell) {        if (cell == null) return false;        boolean bDate = false;        double d = cell.getNumericCellValue();        if ( DateUtil.isValidExcelDate(d) ) {            CellStyle style = cell.getCellStyle();            if(style==null) return false;            int i = style.getDataFormat();            String f = style.getDataFormatString();            bDate = isADateFormat(i, f);        }        return bDate;    }