写一个类

public class LocalDateConverter implements Converter<LocalDateTime> {
@Override
public Class supportJavaTypeKey() {
return LocalDateTime.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return null;
}
@Override
public WriteCellData<?> convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
LocalDate localDate = value.toLocalDate();
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return new WriteCellData<>(localDate.format(dateTimeFormatter));
}
}
在导出的实体类,有时分秒问题的属性上使用该类的反射

宽度调整
