Xavier-
In that case I would suggest populate an item in Message_en_US.properties such as
Date.Format = MM//DD//YYYY

and Message_fr_FR.properties contains your locale specific item for formatting date
Date.Format = DD//MM//YYYY

then in your jsp..
    Locale locale=null;
    if (lang.equals("French"))
   {
        locale=Locale.FRANCE;
    }
   else
   {
        locale=Locale.US;
    }
/obtain the ResourceBundle for your locale
    ResourceBundle bundle =ResourceBundle.getBundle("Message",locale);
//iterate thru all items..
    for (Enumeration e = bundle.getKeys();e.hasMoreElements();)
    {
//obtain the key
        String key = (String)e.nextElement();
//get the string associated with the key value (from Resource Bundle)
        String s = bundle.getString(key);
        if (key.equals(new String("Date.Format")) )
        { //get a DateInstance
           DateFormat df = DateFormat.getDateInstance();
           //initialise to format specified from Resource Bundle
           Date mydate = df.parse(s);
           //put in proper output format for print
           output.println(df.format(mydate);
         }
    }
That sort of thing..
Anyone else ???
Martin-

----- Original Message ----- From: "Xavier Vanderstukken" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Saturday, November 05, 2005 12:31 PM
Subject: Re: Date pattern


OK thanks but I already think to put the user date pattern in the i18n resources files, but I just would like to have a programmatic way to read the date pattern instead of the other one.
Thanks for you response

Martin Gainty wrote:

Xavier-

WebLogic solution
http://e-docs.bea.com/wls/docs81/console_ext/localization.html#1104706

But in In the purest Java sense you can populate your Message_fr_FR.properties Application Resources file
http://www.javaworld.com/javaworld/jw-03-2000/jw-03-ssj-jsp.html#resources

The construct your simpleDateFormat using string passed in and the supplied Locale
http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html#SimpleDateFormat(java.lang.String,%20java.util.Locale)
Important Note: Message items can be referenced via Bean:message taglib

Anyone else ?
Martin-


----- Original Message ----- From: "Xavier Vanderstukken" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Saturday, November 05, 2005 5:13 AM
Subject: Date pattern


I would like to retrieve the date format pattern according to the user Locale.

I  do the following to retrieve the Struts Locale :
Locale current=(Locale)this.pageContext.getSession().getAttribute(Globals.LOCALE_KEY);
if(current==null)
           current=Locale.US;

And now I would like to read something like : MM/DD/YYYY for US locale or DD/MM/YYYY for FR.
How can I do that?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to