You could use String as the property type, and have another method to retrieve
the data as a date for the database's use:
MyForm {
private String dateStr; // may not be valid date
String getDateStr() { return dateStr;}
String setDateStr(String value) {... /* validate with DateFormat
somewhere*/ }
Timestamp getDate() { /* parse dateStr using DateFormat - throw exception
if invalid */ }
}
Don't store dates as Strings in the database - you and anyone else who uses the
database will regret it.
GABOREAU Véronique wrote:
> Hi,
>
> I have the following problem : in my JSP, I have a form containing some date
> fields. The value of these date fields is then saved in a database under the
> Sql Date format.
>
> My problem is that, during the populating of the form bean, the
> populate(...) method cannot convert input text into Date format.
>
> Should I use the String type for dates in the form bean ? (but then I need
> to convert them as Date before inserting in the database).
>
> Does somebody have any idea how I could handle the dates ?
>
> Thanks in advance for any advice.
>
> Veronique Gaboreau.