If I remember correctly you are using Spring MVC? If you are displaying the dates in a form, and you are using the Spring form tags to bind them to the form, then you need to register a customised instance of the CustomDateEditor to convert to/from your chosen format. If you are displaying the dates in a simple list, then the <fmt:formatDate .../> tag should be used.
Mike. On 7/11/07, Msarda <[EMAIL PROTECTED]> wrote:
Thanks a lot Matt. It's working now,but the thing is it will take 42/42/9999 also. I have more problem,i have a jsp engagementforms.jsp which displays all the request submitted by user. When the user enters date it takes in dd/mm/yyyy format,but when showing in engagementforms.jsp ,it shows in MM/dd/yyyy. I tried aading custom validator in it's controller but was getting same output. Thanks in advance. mraible wrote: > > This may help: > > http://jroller.com/page/raible?anchor=validating_dates_with_commons_validator > > Matt > > On 7/10/07, Msarda <[EMAIL PROTECTED]> wrote: >> >> Hi All, >> >> I am trying to validate date field in validation.xml file but getting >> error >> message that the date entered is not a date. >> I have priorityDate field in model object with type java.util.Date. >> I have used customDateBinder in my controller as.. >> >> >> public void initBinder(HttpServletRequest request, >> ServletRequestDataBinder >> binder) { >> String dateFormat = >> getMessageSourceAccessor().getMessage("format.date", >> "dd/MM/yyyy"); >> SimpleDateFormat df = new SimpleDateFormat(dateFormat); >> df.setLenient(true); >> binder.registerCustomEditor(java.util.Date.class, new >> CustomDateEditor( >> df, true)); >> >> } >> >> In validation.xml file i have --- >> >> >> <field property="priorityDate" depends="date"> >> <arg0 key="engagementform.priorityDate"/> >> </field> >> >> I tried with.. >> <field property="priorityDate" >> depends="mask"> >> <msg >> name="mask" >> key="errors.date"/> >> >> <arg0 key="engagementform.priorityDate"/> >> <var> >> <var-name>mask</var-name> >> <var-value>${dateformat}</var-value> >> </var> >> </field> >> where dateformat is >> >> <constant> >> <constant-name>dateformat</constant-name> >> >> <constant-value>^((0[1-9]|[1-2][0-9]|30|31)[/](0[1-9]|11|12)[/](19|20)\d\d)$</constant-value> >> </constant> >> >> I also tried with... >> >> <field property="priorityDate" depends="date"> >> <arg0 key="engagementform.priorityDate"/> >> <var> >> <var-name>datePattern</var-name> >> <var-value>dd/MM/yyyy</var-value> >> </var> >> </field> >> >> But in all the cases i was getting the same problem. :( >> Even if i was entering the date in correct format,i was getting errro >> message that priority date is not date. :( >> Can anybody help in thi sissue please. >> >> Thanks in advance. >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/Problem-with-date-validation-tf4054363s2369.html#a11516397 >> Sent from the AppFuse - User mailing list archive at Nabble.com. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > http://raibledesigns.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Problem-with-date-validation-tf4054363s2369.html#a11533585 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]