private Calendar dob = Calendar.getInstance();
public String getDayOfBirth() { int dayInt = dob.get(Calendar.DAY_OF_MONTH); return Integer.parseInt(dayInt); }
public void setDayOfBirth(String month) { int monthInt = Integer.parseInt(month); this.dob.set(Calendar.DAY_OF_MONTH,monthInt); }
public Calendar getDob() { return dob; }
public void setCalendar(Calendar dob) { this.dob = dob; }
I should warn you that you need to validate input in a validate method to in case the day is out of range for the given calendar month. Unless you generate your select menus when the user changes the month and year.
Some folk will frown upon such practice and claim its not MVC, I could be wrong but I disagree. And also gets the action form doing a little more work.
Mark
On 26 Jun 2004, at 13:24, 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).
Obviously TIMESTAMP have the limitation since date of birth before Jan 1 1970 will be stored as 00000000000. Know any workaround to this one ?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]