Re: fmt:formatDate and fmt:setLocale problem
"Kris Schneider" <[email protected]> Tue, 30 Oct 2007 15:40:53 -0400
| Newsgroups | gmane.comp.jakarta.taglibs.user |
|---|---|
| Message-ID | <[email protected]> |
On 10/30/07, Jdev123 <[email protected]> wrote: > > Hi, > > Thanks for the Quick response. > > I tried making an new page and the locale was proper as shown below.. > > Config locale: en_GB > Response locale: en_GB > > Date: 30/10/2007 > > But when i tried implementing that in the actual page where i need , it > failed to change the locale for the response although the config locale was > changed as shown. > > Config locale: en_GB Response locale: es_UY Date: 30/10/2007 > > > Today is Tue, 30 Oct 2007 Interesting. That seems to indicate that something else is setting the response's locale after <fmt:setLocale> does it. Do you use any filters in your app? Are there other tags used on the page that might set the response's locale? > Kris Schneider wrote: > > > > On 10/30/07, Jdev123 <[email protected]> wrote: > >> > >> Hi , > >> > >> Even i am facing the problem with the locale setting. I tried what ever > >> you > >> mentioned but all in vain > >> if you have found any solution please help. > > > > Can you try running the test I previously posted and include your > > results? Create a JSP with *only* this code in it: > > > > <%@ page contentType="text/plain" > > import="javax.servlet.jsp.jstl.core.Config" %> > > <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> > > > > <fmt:setLocale value="pl_PL"/> > > > > Config locale: <%= Config.find(pageContext, Config.FMT_LOCALE) %> > > Response locale: ${pageContext.response.locale} > > > > <jsp:useBean id="date" class="java.util.Date"/> > > Date: <fmt:formatDate value="${date}" type="date" dateStyle="medium"/> > > > >> kschneid wrote: > >> > > >> > Per the spec, make sure <fmt:setLocale> is placed at the beginning of > >> the > >> > page, > >> > or at least before any other i18n-capable formatting actions. Can you > >> try > >> > the > >> > following: > >> > > >> > <%@ page contentType="text/plain" > >> > import="javax.servlet.jsp.jstl.core.Config" > >> > %> > >> > <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> > >> > > >> > <fmt:setLocale value="pl_PL"/> > >> > > >> > Config locale: <%= Config.find(pageContext, Config.FMT_LOCALE) %> > >> > Response locale: ${pageContext.response.locale} > >> > > >> > <jsp:useBean id="date" class="java.util.Date"/> > >> > Date: <fmt:formatDate value="${date}" type="date" dateStyle="medium"/> > >> > > >> > I get: > >> > > >> > Config locale: pl_PL > >> > Response locale: pl_PL > >> > Date: 2007-06-28 > >> > > >> > If I remove <fmt:setLocale>, I get: > >> > > >> > Config locale: null > >> > Response locale: en_US > >> > Date: Jun 28, 2007 > >> > > >> > So it seems to be working... > >> > > >> > Quoting Java Programmer <[email protected]>: > >> > > >> >> Hi, > >> >> I have problem with using fmt:formatDate and fmt:setLocale - I use: > >> >> > >> >> <fmt:setLocale value="pl_PL" /> > >> >> <fmt:formatDate value="${loggeduser.createDate}" type="date" > >> >> dateStyle="MEDIUM" /> > >> >> > >> >> But my browser sends en_EN locale as prefered, so I cannot get date > >> >> formated in pl_PL they are always formated with browser's en_EN one - > >> >> is there any way to change this behaviour eg. NOT to take browser > >> >> prefered locales and use application ones? > >> >> > >> >> Best regards, > >> >> Adr > >> > > >> > -- > >> > Kris Schneider <mailto:[email protected]> > >> > D.O.Tech <http://www.dotech.com/> > >> > > >> > --------------------------------------------------------------------- > >> > To unsubscribe, e-mail: [email protected] > >> > For additional commands, e-mail: [email protected] > >> > > >> > > >> > > >> :-(:-(:-(:-(:-( > >> -- > >> View this message in context: > >> http://www.nabble.com/fmt%3AformatDate-and-fmt%3AsetLocale-problem-tf3994397.html#a13491375 > >> Sent from the Taglibs - User mailing list archive at Nabble.com. > > > > -- > > Kris Schneider <mailto:[email protected]> > > directThought <http://www.directThought.com/> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > > > > -- > View this message in context: http://www.nabble.com/fmt%3AformatDate-and-fmt%3AsetLocale-problem-tf3994397.html#a13492997 > Sent from the Taglibs - User mailing list archive at Nabble.com. -- Kris Schneider <mailto:[email protected]> directThought <http://www.directThought.com/>