struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <>
Subject Re: SV: date format problems
Date Fri, 07 Mar 2003 14:39:53 GMT
On Fri, 7 Mar 2003 15:26:49 +0100
Søren Blidorf <> wrote:

> Yes, it's a good point, but the only place my date is a String, is in
> the ActionForm.
> Would you store the date as long there?

With all due respect to apachep2 I would store myDate as a String in an
ActionForm bean and then in your business class you store your Date as
the Date you want (I prefer java.util.Date).

So now the question becomes how do you quickly copy all of your String
form bean properties into this business bean that has a type:

In your action you submit to you do:

BeanUtils.copyProperties( yourBusinessBean, yourActionFormBean )

BUT, as you have realized copyProperties will not work for
java.util.Date. So you need to register a converter.

I posted about this a while a back and a search of the archives reveals
the link below. I would change one thing though... following Craig's
suggestion it's cleaner to register the converter as a Plugin which you
can do easily in your struts-config file. Since all my DispatchAction
classes extend a BaseAction I registered the converter there in a static
block, which works, but it's just cleaner as a Plugin since you could
easily swap out the converter at a later time.

Let me know if this link helps. If you are still having trouble let me

Rick Reumann

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message