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
发布评论