Browse Source

Merge branch 'dev_workdiary_service' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_workdiary_service

master
wangxianzhang 3 years ago
parent
commit
2f2cb509fd
  1. 47
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/converter/DateConverter.java

47
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/converter/DateConverter.java

@ -0,0 +1,47 @@
package com.epmet.commons.tools.utils.poi.excel.converter;
/**
* desc:
*
* @author: LiuJanJun
* @date: 2022/8/26 4:59 下午
* @version: 1.0
*/
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.text.SimpleDateFormat;
import java.util.Date;
package com.lxj.common.convert;
/**
* @Author: liujianjun
* @Date: 2022/7/19
* @Description: yyyy-MM-dd easyExcel 日期转换
*/
public class DateConverter implements Converter<Date> {
private static final String PATTERN_YYYY_MM_DD = "yyyy-MM-dd";
@Override
public Class<?> supportJavaTypeKey() {
return Converter.super.supportJavaTypeKey();
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return Converter.super.supportExcelTypeKey();
}
@Override
public WriteCellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_YYYY_MM_DD);
String dateValue = sdf.format(value);
return new WriteCellData<>(dateValue);
}
}
Loading…
Cancel
Save