Announcement Announcement Module
No announcement yet.
Newbie Question: setting with Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie Question: setting with

    I seem to be having a problem with dates, and I can't seem to find the appropriate docs to explain if what I'm trying to do is correct or not.

    I have a bean def such as..

    <bean id="somebean" class="MyBean">
    <property name="someDate">

    This doesn't seem to work and generates...
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.util.Date]

    Should I be using a custom PropertyEditor here for Dates or am I just using a bad string format for the date? Or am going down a completely wrong path?

  • #2
    Should I be using a custom PropertyEditor here for Dates
    Yes .

    Refer to section 3.9 and 3.13 of the reference manual (

    Alef Arendsen[/url]


    • #3
      Date Property Editor

      Are there any typical Date Property editors available?

      If i'm understanding the docs correctly PropertyEditors are also used for the the Web data binding to command objects. Is there a best practices example for dealing with dates on forms in an i18n way?

      Thanks, for the help.

      Roy Wells


      • #4
        For dates you can actually just use CustomDateEditor, a premade PropertyEditor for dates. The easiest way to register and use it in an application context is via CustomeEditorConfigurer (take a look at the JavaDocs of the latter). When you specify the CustomDateEditor bean, you will just have to provide the date format string.


        • #5

          Thanks Colin,

          I think that clears things up a bit. I've located the javadoc on CustomDateEditor and it's comments on BaseCommandController are helpfull.

          Roy Wells