Issue
<bean id="date" class="java.util.Calendar.getInstance" />
how can i inject Calendar instance Please help
i am confused what to use ,i am new to spring In date where new keyword is required is fine but here what have to do
Solution
In a <bean>
declaration class
should specify the complete classname. getInstance
is a factory method & hence it should be as follows:
<bean id="date" class="java.util.Calendar" factory-method="getInstance"/>
It might be better to use the java.time
classes introduced in Java 8, rather than the old java.util.Calendar
& java.util.Date
.
<bean id="date" class="java.time.LocalDate" factory-method="now">
NB: Nevertheless, I can't think of a valid use case, to have the date as a bean.
Answered By - Nice Books