• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CustomEditorConfigurer Exception

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Could you please point out why I get the following exception while trying to use CustomEditorConfigurer? Thanks in advance for your time.

org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property 'dt'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: No matching editors or conversion strategy found

My configuration file contains the following:

<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean class="MyDateEditor"></bean>
</entry>
</map>
</property>
</bean>

My property editor is defined below:

public class MyDateEditor extends PropertyEditorSupport
{
private String dt;
public void setAsText(String text) throws IllegalArgumentException
{
this.dt = text;
Date dtobj= new Date(dt);
setValue(dtobj);
}
}

My Bean class

public class Story
{
private String title;
private String author;
private String content;
private Date dt;
//accessors for other fields go here...
public Date getDt()
{
return dt;
}
public void setDt(Date dt)
{
this.dt = dt;
}
}
reply
    Bookmark Topic Watch Topic
  • New Topic