commit
5e02b7517f
|
@ -8,7 +8,7 @@ import com.fhs.core.trans.constant.TransType;
|
|||
import com.fhs.core.trans.vo.TransPojo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.maku.framework.common.excel.DateConverter;
|
||||
import net.maku.framework.common.excel.LocalDateTimeConverter;
|
||||
import net.maku.framework.common.utils.DateUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -61,9 +61,9 @@ public class SysLogLoginVO implements Serializable, TransPojo {
|
|||
@ExcelProperty(value = "操作信息")
|
||||
private String operationLabel;
|
||||
|
||||
@ExcelProperty(value = "创建时间", converter = DateConverter.class)
|
||||
@ExcelProperty(value = "创建时间", converter = LocalDateTimeConverter.class)
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.fhs.core.trans.anno.Trans;
|
|||
import com.fhs.core.trans.constant.TransType;
|
||||
import com.fhs.core.trans.vo.TransPojo;
|
||||
import lombok.Data;
|
||||
import net.maku.framework.common.excel.DateConverter;
|
||||
import net.maku.framework.common.excel.LocalDateTimeConverter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -63,7 +63,7 @@ public class SysUserExcelVO implements Serializable, TransPojo {
|
|||
@ExcelProperty(value = "超级管理员")
|
||||
private String superAdminLabel;
|
||||
|
||||
@ExcelProperty(value = "创建时间", converter = DateConverter.class)
|
||||
@ExcelProperty(value = "创建时间", converter = LocalDateTimeConverter.class)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package net.maku.framework.common.excel;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
import net.maku.framework.common.utils.DateUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 日期转换
|
||||
*
|
||||
* @author eden
|
||||
*/
|
||||
public class LocalDateTimeConverter implements Converter<LocalDateTime> {
|
||||
|
||||
@Override
|
||||
public Class<LocalDateTime> supportJavaTypeKey() {
|
||||
return LocalDateTime.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
String dateString = cellData.getStringValue();
|
||||
return dateString == null ? null : LocalDateTimeUtil.parse(dateString, DateTimeFormatter.ofPattern(DateUtils.DATE_TIME_PATTERN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<LocalDateTime> convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
String dateValue = LocalDateTimeUtil.format(value, DateUtils.DATE_TIME_PATTERN);
|
||||
return new WriteCellData<>(dateValue);
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ package net.maku;
|
|||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
import net.maku.framework.common.excel.DateConverter;
|
||||
import net.maku.framework.common.excel.ExcelFinishCallBack;
|
||||
import net.maku.framework.common.excel.LocalDateTimeConverter;
|
||||
import net.maku.framework.common.utils.ExcelUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class EasyExcelTest {
|
|||
@ExcelProperty("小数")
|
||||
private Double decimals;
|
||||
|
||||
@ExcelProperty(value = "日期", converter = DateConverter.class)
|
||||
@ExcelProperty(value = "日期", converter = LocalDateTimeConverter.class)
|
||||
private LocalDateTime date;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user