Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Struts and the fly likes date field in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "date field in struts" Watch "date field in struts" New topic

date field in struts

kalyan chowdary

Joined: Jun 22, 2006
Posts: 24

I have a jsp with date filed , date is came from date picker.

Its fine date is came from datapicker, but how to set method for formbean,

I take it as a String , but return value null in action.

How to set this

Help me

Thans in advance
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I generally store a date as type java.util.Date and have two sets of getter/setter pairs for each date -- one set that treats it as a String, and the other that treats it as a Date. Here's an example:

This code assumes that the date is being checked for valid format elsewhere in the code. In the JSP, you would then write:
<html:text property="formattedBirthDate" />
[ June 29, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
I agree. Here's the link:
subject: date field in struts
It's not a secret anymore!