Example usage for org.apache.poi.xssf.usermodel XSSFCell getDateCellValue

List of usage examples for org.apache.poi.xssf.usermodel XSSFCell getDateCellValue

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFCell getDateCellValue.

Prototype

@Override
public Date getDateCellValue() 

Source Link

Document

Get the value of the cell as a date.

Usage

From source file:net.mcnewfamily.rmcnew.shared.Util.java

License:Open Source License

public static void copyXSSFCell(XSSFCell srcCell, XSSFCell destCell) {
    if (srcCell != null && destCell != null) {
        switch (srcCell.getCellType()) {
        case Cell.CELL_TYPE_STRING:
            destCell.setCellType(Cell.CELL_TYPE_STRING);
            destCell.setCellValue(srcCell.getRichStringCellValue());
            break;
        case Cell.CELL_TYPE_NUMERIC:
            destCell.setCellType(Cell.CELL_TYPE_NUMERIC);
            if (DateUtil.isCellDateFormatted(srcCell)) {
                destCell.setCellValue(srcCell.getDateCellValue());
            } else {
                destCell.setCellValue(srcCell.getNumericCellValue());
            }//from   w  w w  . j  a  va  2s .c  o  m
            break;
        case Cell.CELL_TYPE_BOOLEAN:
            destCell.setCellType(Cell.CELL_TYPE_BOOLEAN);
            destCell.setCellValue(srcCell.getBooleanCellValue());
            break;
        case Cell.CELL_TYPE_FORMULA:
            destCell.setCellType(Cell.CELL_TYPE_FORMULA);
            destCell.setCellValue(srcCell.getCellFormula());
            break;
        }
        copyXSSFCellStyle(srcCell, destCell);
    } else {
        throw new IllegalArgumentException("Cannot copy from / to null XSSFCell!");
    }
}