How can I have a data field of type "Date" in my struts form (corresponding to an entry in a jsp page)? The form class generally has getters and setters for String and Boolean, not "Date".

WarnerJan Veldhuis

Create a field as Date and in the setter convert the String parameter to a Date. To quickly convert the date, use:

theDate = DateFormat.getDateInstance().parse(myDateParameter);

In the getter, format the date into whatever String you want on your screen:
return DateFormat.getDateInstance().format(theDate);
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact