Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6008343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:48:38+00:00 2026-05-23T01:48:38+00:00

I have a form which has a date. I registered a customDateEditor for converting

  • 0

I have a form which has a date. I registered a customDateEditor for converting the user input String to date.

public class CategoryExclusionFormController extends SimpleFormController {
  private ModelMap modelMap = new ModelMap();

protected final Log logger = LogFactory.getLog(getClass());

private ExclusionDAO exclusionDAO;

public ExclusionDAO getExclusionDAO() {
    return exclusionDAO;
}

public void setExclusionDAO(ExclusionDAO exclusionDAO) {
    this.exclusionDAO = exclusionDAO;
}

public ModelAndView onSubmit(Object command)
        throws ServletException {
    return new ModelAndView(new RedirectView(getSuccessView()));
}

protected Object formBackingObject(HttpServletRequest request) throws ServletException {
        CatExclCriteria catExcl = new CatExclCriteria();
        return catExcl;
}

@Override
protected Map referenceData(HttpServletRequest request) throws Exception {
    modelMap.put("categories", exclusionDAO.getCategories());
    modelMap.put("statuses", exclusionDAO.getStatuses());
    return modelMap;
}

@InitBinder
public void initBinder(WebDataBinder binder) {
    DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class,"endDate", new CustomDateEditor(
            dateFormat, false));

}
}

My jsp has

Enter the start date in MM-dd-YYYY format

 <form:input path="endDate" />


 </form:form>

My appname-servlet.xml has

  <bean name="/categoryExcl.htm" class="com.lsr.CategoryExclusionFormController">
    <property name="sessionForm" value="true"/>
    <property name="commandName" value="catExcl"/>
    <property name="commandClass" value="com.lsr.model.CatExclCriteria"/>
    <property name="formView" value="categoryExclusion"/>
    <property name="successView" value="home.htm"/>
    <property name="exclusionDAO" ref="exclusionDAO"/>
   </bean>

When I enter the date and hit submit, I am getting the following error

 Field error in object 'catExcl' on field 'endDate': rejected value [05-12-2011];
 codes [typeMismatch.catExcl.endDate,typeMismatch.endDate,typeMismatch.java.util.Date,typeMismatch];
 arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes
 [catExcl.endDate,endDate]; arguments []; default message [endDate]];
 default message   
 [Failed to convert property value of type [java.lang.String] to required type
 [java.util.Date] for property 'endDate'; nested exception is
 java.lang.IllegalArgumentException: 
 Cannot convert value of type [java.lang.String] to required type [java.util.Date] for
 property 'endDate': no matching editors or conversion strategy found],

I am not sure why it is not using the customDateEditor. I’ve seen answers to the related questions but I couldn’t find the error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:48:39+00:00Added an answer on May 23, 2026 at 1:48 am

    Shot in the dark; try simply overriding the initBinder() method:

    @Override
    public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
        DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class,"endDate", new CustomDateEditor(
                dateFormat, false));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form which asks the user his or her date of birth.
I have a form which has a lot of SELECTs. For various reasons, I'd
I have a ASP.NET page which has a form on it. It also has
I have an ASP.NET page which has a script manager on it. <form id=form1
I have a form which takes both the user details and an image uploaded
I have a form in which the user can choose a component type from
I have a form in MS Access which has an image. The image has
Say I have a Form object which has an array of Tab objects. var
I have a form which at some point in its life has three choices.
I have a strong typed view model and a MetaData partial class which has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.