• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

date validation in struts 2

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to compare two dates startDate and endDate . rules are defined in PersonAction-add-validation.xml ..the rest fields are doing fine .but date comparison is not working ...any idea how to compare that enddate should be greater than start date and also that both are mandatory ...n also do we need to define any date format ??..if yes ..how to define format..
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may be possible using the built-in validation, but I am not sure if I would trust it. You have to consider that you may have a user who uses a different format than you are hoping for... 2/1/2007 means Feb. 1, 2007 to me, but Jan. 2, 2007 to some. IIUC, Struts2 will attempt to make a "best guess" as to which date format the user will be entering, but IMO, that may not be enough. Whenever I've dealt with dates in the past, I'll make a set of dropdowns which name the month by their proper name, then a separate input for the day and a dropdown for the year. It is more work for the user entering the date, but it is cleaner for me to handle. If you were dealing with the dates as three separate input fields, you could fairly trivially create an expression that tests that the end date comes after the start date.

-W
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic