本文整理汇总了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);
}