You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Roland Carlsson <ro...@alfa-moving.se> on 2005/04/12 13:06:54 UTC
Format date in textfield
Hi!
I've got an ActionForm that holds a date. The validator checks the format of
the date perfectly and everything is great, almost. When I pre-populate the
ActionForm with a date it will only get it a default-format that is very
wrong for my needs.
How can I format the date that is going to be used in the html-form? Is the
only way to write the input-tag by hand and then use <bean:write
format="yyyy-MM-dd" />?
Thanks for your advice
Roland Carlsson
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Format date in textfield
Posted by Hubert Rabago <hr...@gmail.com>.
When an ActionForm field is used to transmit form data, the
recommendation is to use a String field and let the Action
format/parse its contents. That's what you should do with your date
field. Declare the field in the ActionForm to use java.lang.String,
then populate it with a formatted date in your action before the form
is shown to the user.
Hubert
On Apr 12, 2005 6:06 AM, Roland Carlsson <ro...@alfa-moving.se> wrote:
> Hi!
>
> I've got an ActionForm that holds a date. The validator checks the format of
> the date perfectly and everything is great, almost. When I pre-populate the
> ActionForm with a date it will only get it a default-format that is very
> wrong for my needs.
>
> How can I format the date that is going to be used in the html-form? Is the
> only way to write the input-tag by hand and then use <bean:write
> format="yyyy-MM-dd" />?
>
> Thanks for your advice
> Roland Carlsson
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org