【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)));
	}
}
相关推荐
Victor35617 分钟前
MongoDB(87)如何使用GridFS?
后端
Victor35620 分钟前
MongoDB(88)如何进行数据迁移?
后端
小红的布丁37 分钟前
单线程 Redis 的高性能之道
redis·后端
GetcharZp42 分钟前
Go 语言只能写后端?这款 2D 游戏引擎刷新你的认知!
后端
周末也要写八哥1 小时前
多进程和多线程的特点和区别
java·开发语言·jvm
惜茶2 小时前
vue+SpringBoot(前后端交互)
java·vue.js·spring boot
宁瑶琴2 小时前
COBOL语言的云计算
开发语言·后端·golang
杰克尼2 小时前
springCloud_day07(MQ高级)
java·spring·spring cloud
普通网友2 小时前
阿里云国际版服务器,真的是学生党的性价比之选吗?
后端·python·阿里云·flask·云计算
IT_陈寒3 小时前
Vue的这个响应式问题,坑了我整整两小时
前端·人工智能·后端