当前这是不容易实现的(例如,通过设置简单的配置属性),请参阅#5523。到目前为止,我发现的最佳解决方案是注册一个
Formatter<LocalDate>。这也可以与建模为的可选参数一起使用
Optional<LocalDate>:
@Bean public Formatter<LocalDate> localDateFormatter() { return new Formatter<LocalDate>() { @Override public LocalDate parse(String text, Locale locale) throws ParseException { return LocalDate.parse(text, DateTimeFormatter.ISO_DATE); } @Override public String print(LocalDate object, Locale locale) { return DateTimeFormatter.ISO_DATE.format(object); } }; }当我在#9930中的提案合并后,可以使用配置属性来设置此设置。



