jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32311] - Performance: fmt:formatDate regarding calls to Calendar.getInstance
Date Tue, 23 Nov 2004 09:40:18 GMT
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=32311>.
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=32311





------- Additional Comments From nijlunsing_h@schiphol.nl  2004-11-23 10:40 -------
Since the date patterns, are likely to stay the same on each page. (Because 
usually the date is dynamic, and the date patterns static). Would it be an idea 
to have a pool of SimpleDateFormatters each with its own pattern + locale, so 
we could reuse the same patterns to avoid unnecessary calls to 
Calendar.getInstance?

e.g. in org.apache.taglibs.standard.tag.common.fmt.FormatDateSupport

Something like:
    static Map sdfCache=new HashMap();

    public synchronized SimpleDateFormat getSimpleDateFormat(String pattern, 
Locale locale) {
    	System.out.println("getSimpleDateFormat "+pattern+":"+locale);
    	String key=pattern+locale;
    	SimpleDateFormat sdf;
    	if (sdfCache.containsKey(key)) {
    		sdf=(SimpleDateFormat) sdfCache.get(key);
    	}
    	else {
        	sdf=new SimpleDateFormat(pattern, locale);
        	sdfCache.put(key,sdf);	    		
    	}
    	return sdf;
    }

And later:
Instead of
	    DateFormat formatter = createFormatter(locale);
            // Apply pattern, if present
	    if (pattern != null) {
		try {
		    ((SimpleDateFormat) formatter).applyPattern(pattern);
		} catch (ClassCastException cce) {
		    formatter = new SimpleDateFormat(pattern, locale);
		}
	    }

Something like
	    DateFormat formatter = getSimpleDateFormat (pattern, locale);	
	

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


Mime
View raw message