Of course! Didn't realize that the MessageFormat could have styles. This is a great solution Thanks!
Chris Pratt wrote: > > One way is to use the <s:text> tag. If you define an entry in your > application properties file similar to: > > format.date.long={0,date,long} > > > then you can display a date object in your JSP using: > > <s:text name="format.date.long"><s:param > value="%{user.createDate}"/></s:text> > > The advantage is that each language can have a different definition, if > required, but will use the default formatting for that locale if not. > (*Chris*) > > On Mon, Oct 6, 2008 at 9:18 AM, Björn W > <[EMAIL PROTECTED]>wrote: > >> >> 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: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > -- View this message in context: http://www.nabble.com/tag-for-formatting-date-or-time-using-type-and-style%2C-not-pattern-tp19841154p19841560.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]