You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by bu...@apache.org on 2004/12/31 16:03:36 UTC

DO NOT REPLY [Bug 32904] New: - does not handle locale changes properly - fix included here

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32904>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32904

           Summary: <i18n:formatDate /> does not handle locale changes
                    properly - fix included here
           Product: Taglibs
           Version: nightly
          Platform: All
        OS/Version: Mac OS X 10.3
            Status: NEW
          Severity: major
          Priority: P2
         Component: I18N Taglib
        AssignedTo: taglibs-dev@jakarta.apache.org
        ReportedBy: jack@i90.com


<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.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org