You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by da...@kastortv.org on 2007/08/28 15:55:15 UTC

Using default date format according to current Locale

Hi all !

I'm trying to use pretty correctly Locale with Struts (1.2.8).

I want to display for exemple a Date in current user Locale. Currently I
use this method :
<bean:write name="localizationForm" property="date"
formatKey="format.date.short"/>

with the adequate formatKey in my localized MessageRessources*.properties.
This works perfectly, but...

Since I just put in these .properties default short date format, is there a
convenient way with Struts to use Java native default date format ?

(in other words, I want an output like this, where I don't manually define
the format :
DateFormat sdf = SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT,
locale);
System.out.println(sdf.format(new Date()));
)

Thanks in advance for your help !

Valentin


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


Re: Using default date format according to current Locale

Posted by Paul Benedict <pb...@apache.org>.
Sounds like you want a dynamic property file :-) That's the only thing I can
think of.

On 8/28/07, darfy@kastortv.org <da...@kastortv.org> wrote:
>
>
> Hi all !
>
> I'm trying to use pretty correctly Locale with Struts (1.2.8).
>
> I want to display for exemple a Date in current user Locale. Currently I
> use this method :
> <bean:write name="localizationForm" property="date"
> formatKey="format.date.short"/>
>
> with the adequate formatKey in my localized MessageRessources*.properties.
> This works perfectly, but...
>
> Since I just put in these .properties default short date format, is there
> a
> convenient way with Struts to use Java native default date format ?
>
> (in other words, I want an output like this, where I don't manually define
> the format :
> DateFormat sdf = SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT,
> locale);
> System.out.println(sdf.format(new Date()));
> )
>
> Thanks in advance for your help !
>
> Valentin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>