Meaningless Drivel is fun!
The moose likes Struts and the fly likes Tag Library for Date submission Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Tag Library for Date submission" Watch "Tag Library for Date submission" New topic

Tag Library for Date submission

Jes Sie
Ranch Hand

Joined: Jul 24, 2001
Posts: 188
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.

Thank you.<br /> <br />- Jess Sie<br /> <a href="" rel="nofollow"></a>
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 567
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:

I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
I agree. Here's the link:
subject: Tag Library for Date submission
It's not a secret anymore!