We have this code in our application Context file:
If we register the customDateEditor via initBinder() the Format of Date Attributes is OK.Code:<bean id="dateFormatSql" class="java.text.SimpleDateFormat"> <constructor-arg><value>dd.MM.yyyy HH:mm</value></constructor-arg> </bean> <bean id="customDateEditor" class="org.springframework.beans.propertyeditors.CustomDateEditor"> <constructor-arg index="0"><ref local="dateFormatSql"/></constructor-arg> <constructor-arg index="1"><value>true</value></constructor-arg> </bean> <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.util.Date"> <ref bean="customDateEditor"/> </entry> </map> </property> </bean>
But what can we do to tell the whole Application (all Models) to use this Date format for binding and rendering Dates?Code:protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) { binder.registerCustomEditor(Date.class, null, customDateEditor); }


Reply With Quote