Ejemplo n.º 1
0
  /**
   * Get the value of the cell as a date.
   *
   * <p>For strings we throw an exception. For blank cells we return a null.
   *
   * @return the value of the cell as a date
   * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is
   *     CELL_TYPE_STRING
   * @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
   * @see DataFormatter for formatting this date into a string similar to how excel does.
   */
  public Date getDateCellValue() {
    int cellType = getCellType();
    if (cellType == CELL_TYPE_BLANK) {
      return null;
    }

    double value = getNumericCellValue();
    boolean date1904 = getSheet().getWorkbook().isDate1904();
    return DateUtil.getJavaDate(value, date1904);
  }
Ejemplo n.º 2
0
  /**
   * Get the value of the cell as a date.
   *
   * <p>For strings we throw an exception. For blank cells we return a null.
   *
   * @return the value of the cell as a date
   * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is
   *     CELL_TYPE_STRING
   * @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
   * @see org.zkoss.poi.ss.usermodel.DataFormatter for formatting this date into a string similar to
   *     how excel does.
   */
  public Date getDateCellValue() {
    int cellType = getCellType();
    if (cellType == CELL_TYPE_BLANK) {
      return null;
    }

    double value = getNumericCellValue();
    // TODO: activate this when compiling against 3.7.
    // boolean date1904 = getSheet().getXSSFWorkbook().isDate1904();
    boolean date1904 = false;
    return DateUtil.getJavaDate(value, date1904);
  }