本文整理匯總了Java中org.apache.poi.ss.usermodel.DateUtil.getExcelDate方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtil.getExcelDate方法的具體用法?Java DateUtil.getExcelDate怎麽用?Java DateUtil.getExcelDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.ss.usermodel.DateUtil
的用法示例。
在下文中一共展示了DateUtil.getExcelDate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setValueWithDate_SetsADateValueOnTheCell
import org.apache.poi.ss.usermodel.DateUtil; //導入方法依賴的package包/類
@Test
public void setValueWithDate_SetsADateValueOnTheCell() {
Date date = new Date();
double excelDateNumber = DateUtil.getExcelDate(date);
SpreadsheetCell cell = getCell();
cell.setValue(date);
assertThat(cell.getPoiCell().getCellType())
.isEqualTo(Cell.CELL_TYPE_NUMERIC);
assertThat(cell.getPoiCell().getNumericCellValue())
.isCloseTo(excelDateNumber, within(0.001));
}
示例2: setValueWithCalendar_SetsADateValueOnTheCell
import org.apache.poi.ss.usermodel.DateUtil; //導入方法依賴的package包/類
@Test
public void setValueWithCalendar_SetsADateValueOnTheCell() {
Calendar calendar = Calendar.getInstance();
double excelDateNumber = DateUtil.getExcelDate(calendar.getTime());
SpreadsheetCell cell = getCell();
cell.setValue(calendar);
assertThat(cell.getPoiCell().getCellType())
.isEqualTo(Cell.CELL_TYPE_NUMERIC);
assertThat(cell.getPoiCell().getNumericCellValue())
.isCloseTo(excelDateNumber, within(0.001));
}
示例3: toExcelDate
import org.apache.poi.ss.usermodel.DateUtil; //導入方法依賴的package包/類
private double toExcelDate(Date date) {
return DateUtil.getExcelDate(date);
}
示例4: convertToDaouble
import org.apache.poi.ss.usermodel.DateUtil; //導入方法依賴的package包/類
/**
* 隻能用於excel數據類型
*
* @author shizhongtao
* @param date
* @return
*/
static double convertToDaouble(Date date) {
return DateUtil.getExcelDate(date);
}