Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tag Library for Date submission

 
Jes Sie
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear people,
Does anybody know where can I obtain a Struts Tag Library or a similar example to feature input of Date, Mth and Year values via the HTML/JSP screens?
The String values submitted would then be converted to java.util.Calendar or GregorianCalendar ...hopefully something like 'GregorianCalendar(int year, int month, int date)' ?
FYI, the timezone and time could be just current system defaults.
Thanks. Any help would be much appreciated.
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again Simon,
it's generally held to be best practice to use a string property for all types, not just dates.
In your formbean, you would then convert your original type variable into a string using the locale or fixed US locale or whatever you choose, and then in the formbean.validate() you would convert the user's date string back to date type using your own code.
I've been using this code, but I haven't released it yet, so it's not been tested thoroughly:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic