struts-user mailing list archives

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


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"
<someDateTimeFormtter value="dateObjOnOgnlStack" type="time"

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

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
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?

View this message in context:
Sent from the Struts - User mailing list archive at

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

View raw message