【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)));
	}
}
相关推荐
biyezuopinvip4 小时前
基于Spring Boot的社区互助平台设计与实现(毕业论文)
java·spring boot·vue·毕业设计·论文·毕业论文·社区互助平台设计与实现
J_liaty4 小时前
Redis公共方法详解
spring boot·redis·后端
JNU freshman4 小时前
从 Ceph 16(Pacific)到 Ceph 18(Reef):cephadm 的伸缩性演进与 cephadm agent 到底“成熟”了吗?
java·大数据·ceph
nbsaas-boot4 小时前
为什么 ScopedValue 是 SaaS 的分水岭
java
小北方城市网4 小时前
生产级 Spring Boot + MyBatis 核心配置模板
java·spring boot·redis·后端·spring·性能优化·mybatis
卓怡学长4 小时前
m119在线购书商城系统
java·数据库·spring boot·spring·汽车
haokan_Jia4 小时前
【java使用LinkedHashMap进行list数据分组写入,顺序并没有按照原始顺序,原因分析】
java·开发语言·list
C雨后彩虹4 小时前
中文分词模拟器
java·数据结构·算法·华为·面试
a努力。4 小时前
蚂蚁Java面试被问:流批一体架构的实现和状态管理
java·后端·websocket·spring·面试·职场和发展·架构
计算机学姐4 小时前
基于SpringBoot的在线骑行网站系统
java·vue.js·spring boot·后端·mysql·spring·tomcat