java.time.format.DateTimeParseException: Text ‘‘ could not be parsed at index 0

编程入门 行业动态 更新时间:2024-10-08 22:11:13

java.time.<a href=https://www.elefans.com/category/jswz/34/1745339.html style=format.DateTimeParseException: Text ‘‘ could not be parsed at index 0"/>

java.time.format.DateTimeParseException: Text ‘‘ could not be parsed at index 0

解决方案:

@Component
public class DataConverter implements Converter<String, LocalDate> {@Overridepublic LocalDate convert(String s) {try {return LocalDate.parse(s, DateTimeFormatter.ofPattern("yyyyMMdd"));} catch (Exception e) {e.printStackTrace();}return null;}@Overridepublic JavaType getInputType(TypeFactory typeFactory) {return null;}@Overridepublic JavaType getOutputType(TypeFactory typeFactory) {return null;}
}

在实现接口Converter时可能是因为导入的包不对,若改成:

import com.fasterxml.jackson.databind.util.Converter;

则测试成功!

更多推荐

java.time.format.DateTimeParseException: Text ‘‘ could not be parsed at index 0

本文发布于:2024-02-06 01:43:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1745907.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:format   time   java   DateTimeParseException   index

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!