struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Björn W <bjorn.wennerst...@nodensa.com>
Subject tag for formatting date or time using type and style, not pattern
Date Mon, 06 Oct 2008 16:18:15 GMT

Hi

Is there a way to output localized dates and times from a jsp using the
locale from the request object, not using hardcoded DateFormat pattern in
the jsp? I want to be able to write things like: 
<someDateTimeFormtter value="dateObjOnOgnlStack" type="date"
dateStyle="SHORT"/>
<someDateTimeFormtter value="dateObjOnOgnlStack" type="time"
dateStyle="SHORT"/>

The struts <date> tag does use the current locale, but unfortunately it
doesn't have type and style attributes, so it always gets both the date and
time.

JSTL has the <formatDate> tag which does exactly the right thing, but it
seems to me that JSTL doesn't fit so well on top of Struts 2 (haven't
managed to communicate the Date object from the OGNL stack to the JSTL tag).
The Struts cookbook
http://struts.apache.org/2.x/docs/exposing-framework-objects-to-jstl-with-a-jstl-and-displaytag-example.html
on the subject doesn't really help me much.

An option is to use the struts <text> tag with the Date object as a
parameter and the format strings copied into the different resource bundles,
but that's obviously not a very attractive solution...

I could of course write the tags myself but this really seems like such a
common problem that it must be done somewhere already?

Thanks,
Björn
-- 
View this message in context: http://www.nabble.com/tag-for-formatting-date-or-time-using-type-and-style%2C-not-pattern-tp19841154p19841154.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message