How can I use the @Value annotation to configure the Joda-Time period field in my spring bean?
eg. Given the following class of components:
@Component public class MyService { @Value("${myapp.period:P1D}") private Period periodField; ... }
I want to use the standard ISO8601 format to define the period in a property file.
I get this error:
Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.joda.time.Period]: no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:302) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:125) at org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:61) ... 35 more
source share