Eddie Yan wrote:

Anyone know what is the best practices to store a person
date of birth ? How should we design our detail object, JSP and database
in such way we don't have a messy approached to populate the day,
month and year in Action class to be able to display in JSP during UPDATE
process.

Currently, I have a JSP with combo box for day, month and year.
Using mySQL db, I set the dateOfBirth column to TIMESTAMP.
(Some told me to use DATE for this column).

I tend to do it slightly different than Mark's approach or yours above using combo boxes. I like to let the user be able to free form type in the date and also provide the option of calendar date picker (plenty of free javascript ones out there). I hate having to select each part of the date from a drop down since I can type in a date pretty quickly (If the user hates typing that's what the calendar picker is for).


I usually put the format I want next to the date field in the JSP as defined as bean message property that can be looked up in the ApplicationResources file (ie form.date.format=mm/dd/yy ). Not only is this good in case you want to deal with localization issues, but it's nice if someone comes to you and says "Product Manager John Doe would rather the user's enter the date as mm-dd-yyyy instead of mm/dd/yy"

The form field I take is a simple String. I then validate using the validator framework or simply validate in the Action itself. (If you use the validator framework you have to register your date converter, but once registered it's set for the whole application so you only do it once. If you want to go that route I can show you how to do it.. there are some posts in the archives here how to do it also). When needing to display the date back in the form it's just as easy when you have that converter registered since BeanUtils can convert it correctly for you.

I like the flexibility of this approach. I can see the benefit also of having the ActionForm return the Date formats you want, but it's not my preferred way of doing it.


-- Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to