【Excel】- 导入报错Can not find ‘Converter‘ support class LocalDateTime

【Excel】导入报错Can not find 'Converter' support class LocalDateTime

爆错信息

什么意思呢:找不到"转换器"支持类LocalDateTime,就是导入的数据中有LocalDateTime类型的字段,Excel转换不支持LocalDateTime格式,需要写有一个LocalDateTime的转换类;

写转换类

java 复制代码
public class LocalDateTimeConverter implements Converter<LocalDateTime> {
	private static final String DEFAULT_PATTERN="yyyy-MM-dd HH:mm:ss";


	@Override
	public Class<LocalDateTime> supportJavaTypeKey() {
		return LocalDateTime.class;
	}

	@Override
	public CellDataTypeEnum supportExcelTypeKey() {
		return CellDataTypeEnum.STRING;
	}

	@Override
	public LocalDateTime convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
		return LocalDateTime.parse(cellData.getStringValue(), DateTimeFormatter.ofPattern(DEFAULT_PATTERN));
	}

	@Override
	public CellData convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
		return new CellData<>(value.format(DateTimeFormatter.ofPattern(DEFAULT_PATTERN)));
	}
}
相关推荐
钱栈up6 小时前
烧结趋势页台车速度曲线凭空消失:一次\\\"去重\\\"误杀的配置修复
后端·测试
刘小灰12 小时前
返璞归真,我开始更新博客了
前端·后端
一条Go13 小时前
巡检报告:把一次性排障变成可复跑的任务
后端·github
一条Go13 小时前
SQL 实验室:只读靠两把锁,DDL 靠模板
后端·github
一条Go13 小时前
维护窗口与升级策略:静默和升级怎么共存
后端·github
一条Go13 小时前
应用商店:版本、发布与部署为什么必须拆成三个阶段
后端·github
郝学胜-神的一滴13 小时前
Effective STL 条款15:注意字符串实现上的差异
java·开发语言·数据结构·c++·算法·visualstudio
sharemylove13 小时前
Java学习笔记 —— 面向对象专题
java·开发语言·笔记·学习·课程设计
京东云开发者14 小时前
一份数据,两种协议:京东云存储打通文件与对象
后端
代码民工正电荷14 小时前
JAVA学习基础(一)
java·开发语言·学习