No this is not the same post from over a year ago:
http://forum.springframework.org/showthread.php?t=13440
I'm having problems wiring up a date in my appContext. I've followed the same intructions from the post above, the step by step from the book "Professional Java Development with the Spring Framework," and even the online documentation.
But I can't get rid of the cursed:
org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property 'createdOn'
I'm at my wits end and maybe just need a sanity check. Can someone please help?
Here is my appContext:
And my bean definition (located in another file):Code:<bean name="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.util.Date"> <bean class="pe.DatePropertyEditor"> <constructor-arg index="0"> <bean class="java.text.SimpleDateFormat"> <constructor-arg><value>MM/dd/yyyy</value></constructor-arg> </bean> </constructor-arg> <constructor-arg index="1"> <value>true</value> </constructor-arg> </bean> </entry> </map> </property> </bean>
I've replaced the spring CustomDateEditor with my own version that is a duplicate with the exception of added logging to see when my date editor is called:Code:<bean id="ticket1" class="domain.Ticket"> //... <property name="createdOn"> <value>01/11/12</value> </property> //... </bean>
When I run it, I never see the console output. ...Only the cursed, "Failed to convert property..." That seems very strange.Code:public DatePropertyEditor(DateFormat dateFormat, boolean allowEmpty) { System.out.println("Creating date property editor with format: " + dateFormat.toString()); this.dateFormat = dateFormat; this.allowEmpty = allowEmpty; } public void setAsText(String text) throws IllegalArgumentException { System.out.println("Attempting to convert: " + text); if(this.allowEmpty && !StringUtils.isNotBlank(text)) { setValue(null); } else { try { setValue(this.dateFormat.parse(text)); } catch(ParseException ex) { throw new IllegalArgumentException("Could not parse date: " + ex.getMessage()); } } }
Any ideas? I'm crying here.
Thanks!
-Mike


Reply With Quote
