带有物业占位符Spring的LocalDate [英] LocalDate with Property place holder Spring

查看:111
本文介绍了带有物业占位符Spring的LocalDate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring Boot和属性占位符.我有一个值为:date.A=24/07/17的属性文件. 我有一个课程,正在使用@Value批注:

I am working with Spring Boot and property placeholders. I have a property file with the value : date.A=24/07/17. I have a class and I am using the @Value annotation:

@Value("${date.A}")
private LocalDate dateA;

但是运行gradle build integrationTest时出现运行时错误:

But I am getting the runtime error when running gradle build integrationTest:

Caused by: java.time.format.DateTimeParseException: Text '24/07/17' could not be parsed: Invalid value for MonthOfYear (valid values 1 - 12): 24
    at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
    at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1855)
    at java.time.LocalDate.parse(LocalDate.java:400)

推荐答案

日期应在en_US语言环境中指定,因此您需要交换月份和日期:

The date should be specified in en_US locale, so you need to swap the month and day:

date.A=7/24/17

这篇关于带有物业占位符Spring的LocalDate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆