You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by bu...@apache.org on 2004/11/10 09:24:17 UTC

DO NOT REPLY [Bug 28360] - [PATCH] DateInputModule's getAttribute() should fetch format from attribute-name

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();
            }
        }