Treat it like any other POJO (which is)
<property name="dateOfBirth"> <bean class="java.util.Date" /> </property>
If you need to use an explicit value (e.g. 1975-04-10), just call one of the other constructors (although those that take year-month-day are deprecated). You can also use the explicit java.beans.PropertyEditor , which Spring rolls already (see Section 6.4.2 ; that you can write your own editors and register them for your own types). You need to register CustomEditorConfigurer in your configuration:
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.util.Date" value="org.springframework.beans.propertyeditors.CustomDateEditor"/> </map> </property> </bean>
Then your data looks like this:
<property name="dateOfBirth" value="1975-04-10" />
I could add that Date not a suitable data type for storing a date of birth, because Date really instant. You can look at Joda and use the LocalDate class.
oxbow_lakes
source share