You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Louis Leung <lo...@sun.com> on 2003/05/17 01:59:54 UTC
date format w/ text field or bean:write
Hi all,
Anyone know how to format dates when it gets displayed in a text field
(using html:text) or with bean:write ? The dates are Date objects in
the Action Forms. I want to format the display according to the locale
of the user. Any ideas ? :)
Louis
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: date format w/ text field or bean:write
Posted by Vic Cekvenich <vc...@baseBeans.com>.
First you do not want to use bean:write but JSTL (that ships with Sun
Web Services pack 1 and 1.1 :-) )
JSTL has a F (format) tag that lets you "localize" the format. Your form
bean would have a Date getDDate()
So use that a lot.
When using forms (html:text), I would have a baseFormBean (everyone
should have one, as well as baseAction) , the baseFOrmBean should have
getters/setters for locale.
Since html tag is String based, you also need a String getSDate(), that
"localizes" and formats in the getter, and not in tag.
So .... for read only format in JSTP, for R/W, in the getter.
hth,
.V
Louis Leung wrote:
>Hi all,
>
>Anyone know how to format dates when it gets displayed in a text field
>(using html:text) or with bean:write ? The dates are Date objects in
>the Action Forms. I want to format the display according to the locale
>of the user. Any ideas ? :)
>
>
>Louis
>
>
--
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA
Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East.
Open Source <a href ="baseBeans.com">Content Management</a> basicPortal sofware
Best practice<a href ="baseBeans.com">Struts Support</a> v.1.1 helper ScafflodingXPress
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org