Example usage for org.apache.poi.ss.usermodel DateUtil getExcelDate

List of usage examples for org.apache.poi.ss.usermodel DateUtil getExcelDate

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel DateUtil getExcelDate.

Prototype

public static double getExcelDate(Calendar date, boolean use1904windowing) 

Source Link

Document

Given a Date in the form of a Calendar, converts it into a double representing its internal Excel representation, which is the number of days since 1/1/1900.

Usage

From source file:org.eclipse.emfforms.internal.spreadsheet.core.converter.EMFFormsSpreadsheetSingleAttributeConverter_Test.java

License:Open Source License

@Test
public void testGetCellValueXmlDate() throws EMFFormsConverterException {
    final XMLGregorianCalendar cellValue = new XMLCalendar(Calendar.getInstance(UTC_TIMEZONE).getTime(),
            XMLCalendar.DATE);/*from  w w  w .j a v  a 2  s .  com*/
    cellValue.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
    cellValue.setHour(DatatypeConstants.FIELD_UNDEFINED);
    cellValue.setMinute(DatatypeConstants.FIELD_UNDEFINED);
    cellValue.setSecond(DatatypeConstants.FIELD_UNDEFINED);
    cellValue.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);

    cell.setCellValue(DateUtil.getExcelDate(cellValue.toGregorianCalendar(UTC_TIMEZONE, null, null), false));
    final EDataType dataType = EcoreFactory.eINSTANCE.createEDataType();
    dataType.setInstanceClass(XMLGregorianCalendar.class);
    final EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute();
    eAttribute.setEType(dataType);
    final Object value = converter.getCellValue(cell, eAttribute);
    final XMLGregorianCalendar result = (XMLGregorianCalendar) value;
    assertEquals(cellValue, result);
}