You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Victor Neo (JIRA)" <ji...@apache.org> on 2007/05/16 09:54:43 UTC

[jira] Updated: (WW-1792) Date tag doesn't handle calendars

     [ https://issues.apache.org/struts/browse/WW-1792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Victor Neo updated WW-1792:
---------------------------

    Attachment: Date.diff

Patch for the Date tag to handle what the user requested.

(This is my first patch, do tell me what I can do to improve. Thanks)

> Date tag doesn't handle calendars
> ---------------------------------
>
>                 Key: WW-1792
>                 URL: https://issues.apache.org/struts/browse/WW-1792
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Views
>    Affects Versions: 2.0.6
>            Reporter: Mike Baroukh
>            Priority: Minor
>             Fix For: 2.1.x
>
>         Attachments: Date.diff
>
>
> in org.apache.struts2.component.Date, the following code
>         try {
>             date = (java.util.Date) findValue(name);
>         } catch (Exception e) {
>             LOG.error("Could not convert object with key '" + name
>                     + "' to a java.util.Date instance");
>             // bad date, return a blank instead ?
>             msg = "";
>         }
> can handle only Date.
> There is many case where Calendars are used instead of Date and handling Calendar would be trivial :
>         try {
>             Object o = findValue(name);
>             if (o!=null) {
>                         if (o instanceof java.util.Calendar) {
>                                     date = ((java.util.Calendar)o).getTime();
>                         } else {
>                                     date = (java.util.Date) o;
>                         }
>             }
>         } catch (Exception e) {
>             LOG.error("Could not convert object with key '" + name
>                     + "' to a java.util.Date instance");
>             // bad date, return a blank instead ?
>             msg = "";
>         }
> this way, we will not have to call with "obj.time()" anymore resulting in less ognl calls ...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.