【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)));
	}
}
相关推荐
黄雪超几秒前
JVM——从JIT到AOT:JVM编译器的云原生演进之路
java·开发语言·jvm
冰_河2 分钟前
《Nginx核心技术》第10章:Nginx配置WebSocket
后端·nginx·程序员
南雨北斗13 分钟前
windows项目迁移到linux注意事项
后端
yours_Gabriel21 分钟前
【java面试】redis篇
java·redis·面试
虾球xz21 分钟前
CppCon 2014 学习: C++ on Mars
java·开发语言·c++·学习
Brookty38 分钟前
【MySQL】事务
数据库·后端·学习·mysql
Elastic开源社区38 分钟前
Java生态中的NLP框架
java·开发语言·自然语言处理·nlp
羑悻的小杀马特39 分钟前
三大模块曝光:分钟级搭建专属平台,解锁算力灵活操控新体验,重新定义智能开发效率天花板
后端·蓝耘·智能体开发
珂朵莉MM1 小时前
2022 RoboCom 世界机器人开发者大赛(睿抗 caip) -高职组(国赛)解题报告 | 科学家
java·人工智能·python·算法·职场和发展·机器人
风象南1 小时前
SpringBoot慢查询的6种监控方案
java·spring boot·后端