Re: fmt:formatDate and fmt:setLocale problem
Kris Schneider <[email protected]>
| Newsgroups | gmane.comp.jakarta.taglibs.user |
|---|---|
| Message-ID | <[email protected]> |
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/>