cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 28360] - [PATCH] DateInputModule's getAttribute() should fetch format from attribute-name
Date Wed, 10 Nov 2004 08:24:17 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=28360>.
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=28360

[PATCH] DateInputModule's getAttribute() should fetch format from attribute-name





------- Additional Comments From Ralph_Goers@dslextreme.com  2004-11-10 08:24 -------
I have implemented and tested this and found a slight performance impact.

In the sample the input module is specified as {date:date}. In the prior version
whatever was specified after date: was ignored. However, with the change an
exception is thrown because date is not a valid format string.  

The code as implemented is shown below. If it is acceptable I will commit it.

        String format = (String) this.settings.get("format",name);
        if (modeConf != null) {
            format = modeConf.getAttribute("format", format);
            // this is preferred:
            format = modeConf.getChild("format").getValue(format);
        }

        if (format==null) {
            return new Date();
        } else {
            try
            {
                return new SimpleDateFormat(format).format(new Date());
            }
            catch (Exception e)
            {
                return new Date();
            }
        }

Mime
View raw message