You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ha...@informatiefabriek.nl on 2003/10/02 16:36:33 UTC
internationalized date
Hi all,
I have a bean which contains a java.util.Date field which I need to print
in my JSP.
Unfortunatly when I just use:
<bean:write name="myBean" property="date"/>
The date get's printed in the (default) American / English format:
Thu Oct 02 08:58:34 CEST 2003
I need to present a localized version of the date (Dutch standard format).
What is a good way of achieving this?
Many thanks,
Harm de Laat
Informatiefabriek
The Netherlands
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: internationalized date
Posted by Stephan Wiesner <sw...@logicline.de>.
You can use JSTL or write your own Date formatter Custom Tag.
Here is a method that does that:
public int doStartTag() throws JspException
{
Date today = new Date();
ServletRequest request
(ServletRequest)pageContext.getRequest();
Locale user = request.getLocale();
DateFormat dateFormatter =
DateFormat.getDateInstance(DateFormat.DEFAULT, user);
String now = dateFormatter.format(today);
try { pageContext.getOut().write(now);
}catch(java.io.IOException ex)
{ throw new JspException(ex.getMessage()); }
return EVAL_BODY_INCLUDE;
}
harm@informatiefabriek.nl wrote:
> Hi all,
>
> I have a bean which contains a java.util.Date field which I need to print
> in my JSP.
> Unfortunatly when I just use:
>
> <bean:write name="myBean" property="date"/>
>
> The date get's printed in the (default) American / English format:
>
> Thu Oct 02 08:58:34 CEST 2003
>
> I need to present a localized version of the date (Dutch standard format).
>
> What is a good way of achieving this?
>
> Many thanks,
>
> Harm de Laat
> Informatiefabriek
> The Netherlands
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org