【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)));
	}
}
相关推荐
qq_124987075335 分钟前
基于springboot的疾病预防系统的设计与实现(源码+论文+部署+安装)
java·spring boot·后端·毕业设计
麦烤楽鸡翅35 分钟前
简单迭代法求单根的近似值
java·c++·python·数据分析·c·数值分析
火星数据-Tina1 小时前
低成本搭建体育数据中台:一套 API 如何同时支撑比分网与 App?
java·前端·websocket
lcu1111 小时前
Java 学习38:ArrayList 类
java
q***2511 小时前
Spring Boot 集成 Kettle
java·spring boot·后端
筱顾大牛1 小时前
IDEA使用Gitee来创建远程仓库
java·gitee·intellij-idea
懂得节能嘛.2 小时前
【SDK开发实践】从Java编码到阿里云制品仓库部署
java·阿里云·maven
码事漫谈2 小时前
阿里《灵光》生成的视频下载不带水印的极简方法
后端
空空kkk2 小时前
SpringMVC——异常
java·前端·javascript
舒一笑2 小时前
信息的建筑学:MyBatis Log Panda 如何重构开发者的认知地图
后端·sql·intellij idea