Bug 32904 - <i18n:formatDate /> does not handle locale changes properly - fix included here
Summary: <i18n:formatDate /> does not handle locale changes properly - fix included here
Status: RESOLVED WONTFIX
Alias: None
Product: Taglibs
Classification: Unclassified
Component: I18N Taglib (show other bugs)
Version: nightly
Hardware: All Mac OS X 10.3
: P2 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-31 16:03 UTC by John DeNeut
Modified: 2009-07-10 00:36 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John DeNeut 2004-12-31 16:03:36 UTC
<i18n:formatDate /> does not handle Locale changes properly in Tomcat/5.0.16 on
Mac OS X 10.3.6 because the Locale is cached (actually, the DateFormat is
cached, but it ends up causing the same problem). 

The problem is in i18n.FormatDateTag, right here: 

/** If no {@link java.text.DateFormat} is configured then use a 
      * {@link SimpleDateFormat} instance if a pattern is configured else
      * use the default DateFormat for the {@link java.util.Locale}
      */
    public Format getFormat() {
        /* if ( format == null ) { */
            String pattern = getPattern();
            if ( pattern != null ) {
                format = getPatternFormat( pattern );
            }
            if ( pattern == null ) {
                format = getDateFormat();
            }
       /* } */
        return format;
    }

When tags are pooled(?) the variable 'format' gets set the first time the tag is
used in the container, and can then not be changed. The fix is to do what I did
above - that is, take out the check for 'format' being null and simply redo the
formatting every time. 

Note that <i18n:formatDateTime /> works fine.  I used both tags on the same page
and switched my locale back and forth.  <i18n:formatDateTime /> responds to the
change in Locale, but <i18n:formatDate /> does not.  My fix (above) solves this
problem.
Comment 1 Henri Yandell 2009-07-10 00:36:36 UTC
JSTL replaced the i18n taglib, so this won't be worked on.