Bug 45620 - formatDate fails when locale is missing
Summary: formatDate fails when locale is missing
Alias: None
Product: Taglibs
Classification: Unclassified
Component: I18N Taglib (show other bugs)
Version: unspecified
Hardware: All Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Keywords: NeedsReleaseNote
Depends on:
Reported: 2008-08-12 06:34 UTC by Phil Dicke
Modified: 2009-07-10 00:37 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Phil Dicke 2008-08-12 06:34:17 UTC
Some browsers (IE from GoogleEarth) do not pass local information in the HTTP header for the request, therefore request.getLocale() returns null.  When this happens the following tag fails even though a pattern and timezone are specified:

<fmt:formatDate value="${d}" pattern="yyyy-MM-dd HH:mm z" timeZone="GMT"/>
The above just prints out d.toString()

SimpleDateFormat has all the elements it needs for a successful format, it should format the date as expected instead of using d.toString()

You can add the following to your JSP and it will work.
    <c:when test="${request.locale == null}">
        <fmt:setLocale value="en_US" />
Comment 1 Nicky Sandhu 2009-02-09 16:53:37 UTC
Another easy workaround without touching jsp pages is to set either the default fallback locale or the default locale via web.xml configuration
Comment 2 Henri Yandell 2009-07-10 00:37:45 UTC
JSTL replaced the i18n taglib, so this won't be worked on.