This is how I am trying to inject a date into a @Component class.
@Value("${new java.text.SimpleDateFormat(\"yyyyMMdd\").parse(\"${PROP_DATE}\")}")
Date myDate;
The date is specified as a String in properties file :
PROP_DATE=20110421
I get this error. What am I doing wrong? Is there any other way to inject Date property? Thanks.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ccc': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: java.util.Date aaa.bbb.ccc.myDate; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'new java.text.SimpleDateFormat("yyyyMMdd").parse("20110421")'
Use #{new java.text.SimpleDateFormat(\"yyyyMMdd\").parse(\"${PROP_DATE}\")}
for process value with spEL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With