【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)));
	}
}
相关推荐
万邦科技Lafite几秒前
淘宝店铺所有商品API接口实战指南
java·数据库·mysql
jjjxxxhhh12329 分钟前
【加密】-AES与对称加密
java·服务器·网络
临水逸31 分钟前
飞牛fnos 2025 漏洞Java跨域URL浏览器
java·开发语言·安全·web安全
yaoxin52112333 分钟前
324. Java Stream API - 实现 Collector 接口:自定义你的流式收集器
java·windows·python
H Corey33 分钟前
数据结构与算法:高效编程的核心
java·开发语言·数据结构·算法
米羊12144 分钟前
Struts 2 漏洞(上)
java·后端·struts
galaxyffang1 小时前
Java堆内存诊断:从工具使用到实战分析
java·jvm
梵得儿SHI1 小时前
Spring Cloud 实战攻坚:企业级用户服务开发(注册登录 + JWT 认证 + 权限控制)
后端·spring·spring cloud·用户注册与登录·jwt无状态认证体系·rbac权限控制·微服务用户中心
HAPPY酷2 小时前
C++ 成员指针(Pointer to Member)完全指南
java·c++·算法
Sunsets_Red2 小时前
浅谈随机化与模拟退火
java·c语言·c++·python·算法·c#·信息学竞赛