百度站长怎样添加网站android优化大师
【Excel】导入报错Can not find 'Converter' support class LocalDateTime
- 爆错信息
- 写转换类
爆错信息
什么意思呢:找不到“转换器”支持类LocalDateTime,就是导入的数据中有LocalDateTime类型的字段,Excel转换不支持LocalDateTime格式,需要写有一个LocalDateTime的转换类;
写转换类
public class LocalDateTimeConverter implements Converter<LocalDateTime> {private static final String DEFAULT_PATTERN="yyyy-MM-dd HH:mm:ss";@Overridepublic Class<LocalDateTime> supportJavaTypeKey() {return LocalDateTime.class;}@Overridepublic CellDataTypeEnum supportExcelTypeKey() {return CellDataTypeEnum.STRING;}@Overridepublic LocalDateTime convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {return LocalDateTime.parse(cellData.getStringValue(), DateTimeFormatter.ofPattern(DEFAULT_PATTERN));}@Overridepublic CellData convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {return new CellData<>(value.format(DateTimeFormatter.ofPattern(DEFAULT_PATTERN)));}
}