forked from fanruan/easyexcel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
35 lines
1.2 KiB
4 years ago
|
package com.alibaba.excel.converters.localdatetime;
|
||
|
|
||
|
import java.time.LocalDateTime;
|
||
|
|
||
|
import com.alibaba.excel.converters.Converter;
|
||
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||
|
import com.alibaba.excel.metadata.data.WriteCellData;
|
||
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||
|
import com.alibaba.excel.util.DateUtils;
|
||
|
import com.alibaba.excel.util.WorkBookUtil;
|
||
|
|
||
|
/**
|
||
|
* Date and date converter
|
||
|
*
|
||
|
* @author Jiaju Zhuang
|
||
|
*/
|
||
|
public class LocalDateTimeDateConverter implements Converter<LocalDateTime> {
|
||
|
@Override
|
||
|
public Class<LocalDateTime> supportJavaTypeKey() {
|
||
|
return LocalDateTime.class;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public WriteCellData<?> convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty,
|
||
|
GlobalConfiguration globalConfiguration) throws Exception {
|
||
|
WriteCellData<?> cellData = new WriteCellData<>(value);
|
||
|
String format = null;
|
||
|
if (contentProperty != null && contentProperty.getDateTimeFormatProperty() != null) {
|
||
|
format = contentProperty.getDateTimeFormatProperty().getFormat();
|
||
|
}
|
||
|
WorkBookUtil.fillDataFormat(cellData, format, DateUtils.defaultDateFormat);
|
||
|
return cellData;
|
||
|
}
|
||
|
}
|