【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)));
	}
}
相关推荐
石山代码2 小时前
ArrayList / HashMap / ConcurrentHashMap
java·开发语言
AskHarries3 小时前
系统提示词、开发者指令和用户输入的优先级
java·前端·数据库
Moment3 小时前
长上下文会最终杀死 Rag 吗?
前端·javascript·后端
daidaidaiyu3 小时前
ThingsBoard 规则链系统源码分析和自定义定时器
java
蝎子莱莱爱打怪4 小时前
🚀 🚀🚀2026年5月GitHub月榜精选:17个项目中挑出10个推荐,实操4个!
人工智能·后端·ai编程
小毛驴8504 小时前
spring-boot-maven-plugin,maven-compiler-plugin 功能对比
java·python·maven
csdn_aspnet4 小时前
Java 霍尔分区算法(Hoare‘s Partition Algorithm)
java·开发语言·算法
霸道流氓气质4 小时前
通义灵码 IDEA 插件完全使用指南
java·ide·intellij-idea
诸葛务农4 小时前
道路行驶条件下电动汽车永磁电机的有效使用寿命及永磁体的失效和回收再利用(下)
java·开发语言·算法
Percep_gan5 小时前
Java8中的stream的测试使用
java