You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Qiang Zheng (JIRA)" <ji...@apache.org> on 2009/02/19 17:08:46 UTC

[jira] Created: (WW-3005) Attempt to parse empty date in DateTimePicker.java which cause java.text.ParseException Unparseable date: ""

Attempt to parse empty date in DateTimePicker.java which cause java.text.ParseException Unparseable date: "" 
-------------------------------------------------------------------------------------------------------------

                 Key: WW-3005
                 URL: https://issues.apache.org/struts/browse/WW-3005
             Project: Struts 2
          Issue Type: Bug
            Reporter: Qiang Zheng


In following code at DateTimePicker.java, parameters.get("value") will return empty string instead of null when value attribute is specified with null value.
.............
if(parameters.containsKey("value")) {
            parameters.put("nameValue", format(parameters.get("value"))); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        } else {
         
............
private String format(Object obj) {
        if(obj == null)
            return null;

        if(obj instanceof Date) {
            return MessageFormat.format(RFC3339_PATTERN, (Date) obj);
        } else if(obj instanceof Calendar) {
            return MessageFormat.format(RFC3339_PATTERN, ((Calendar) obj).getTime());
        } else {
            // try to parse a date
            String dateStr = obj.toString();
            if(dateStr.equalsIgnoreCase("today"))
                return MessageFormat.format(RFC3339_PATTERN, new Date());

            try {
                Date date = null;
                if(this.displayFormat != null) {
                    SimpleDateFormat format = new SimpleDateFormat(
                            (String) getParameters().get("displayFormat"));
                    date = format.parse(dateStr); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    return MessageFormat.format(RFC3339_PATTERN, date);
                } else {
                    // last resource to assume already in correct/default format
                    return dateStr;
                }
            } catch (ParseException e) {
-------------

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


[jira] Updated: (WW-3005) Attempt to parse empty date in DateTimePicker.java which cause java.text.ParseException Unparseable date: ""

Posted by "Qiang Zheng (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3005?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Qiang Zheng updated WW-3005:
----------------------------

    Affects Version/s: 2.0.14

> Attempt to parse empty date in DateTimePicker.java which cause java.text.ParseException Unparseable date: "" 
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3005
>                 URL: https://issues.apache.org/struts/browse/WW-3005
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.14
>            Reporter: Qiang Zheng
>
> In following code at DateTimePicker.java, parameters.get("value") will return empty string instead of null when value attribute is specified with null value.
> .............
> if(parameters.containsKey("value")) {
>             parameters.put("nameValue", format(parameters.get("value"))); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>         } else {
>          
> ............
> private String format(Object obj) {
>         if(obj == null)
>             return null;
>         if(obj instanceof Date) {
>             return MessageFormat.format(RFC3339_PATTERN, (Date) obj);
>         } else if(obj instanceof Calendar) {
>             return MessageFormat.format(RFC3339_PATTERN, ((Calendar) obj).getTime());
>         } else {
>             // try to parse a date
>             String dateStr = obj.toString();
>             if(dateStr.equalsIgnoreCase("today"))
>                 return MessageFormat.format(RFC3339_PATTERN, new Date());
>             try {
>                 Date date = null;
>                 if(this.displayFormat != null) {
>                     SimpleDateFormat format = new SimpleDateFormat(
>                             (String) getParameters().get("displayFormat"));
>                     date = format.parse(dateStr); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>                     return MessageFormat.format(RFC3339_PATTERN, date);
>                 } else {
>                     // last resource to assume already in correct/default format
>                     return dateStr;
>                 }
>             } catch (ParseException e) {
> -------------

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


[jira] Closed: (WW-3005) Attempt to parse empty date in DateTimePicker.java which cause java.text.ParseException Unparseable date: ""

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3005?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wes Wannemacher closed WW-3005.
-------------------------------

    Resolution: Won't Fix

We are moving away from the dojo integration. If you want to see this fixed, please reopen this issue with a patch file containing a fix.

> Attempt to parse empty date in DateTimePicker.java which cause java.text.ParseException Unparseable date: "" 
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3005
>                 URL: https://issues.apache.org/struts/browse/WW-3005
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.14
>            Reporter: Qiang Zheng
>
> In following code at DateTimePicker.java, parameters.get("value") will return empty string instead of null when value attribute is specified with null value.
> .............
> if(parameters.containsKey("value")) {
>             parameters.put("nameValue", format(parameters.get("value"))); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>         } else {
>          
> ............
> private String format(Object obj) {
>         if(obj == null)
>             return null;
>         if(obj instanceof Date) {
>             return MessageFormat.format(RFC3339_PATTERN, (Date) obj);
>         } else if(obj instanceof Calendar) {
>             return MessageFormat.format(RFC3339_PATTERN, ((Calendar) obj).getTime());
>         } else {
>             // try to parse a date
>             String dateStr = obj.toString();
>             if(dateStr.equalsIgnoreCase("today"))
>                 return MessageFormat.format(RFC3339_PATTERN, new Date());
>             try {
>                 Date date = null;
>                 if(this.displayFormat != null) {
>                     SimpleDateFormat format = new SimpleDateFormat(
>                             (String) getParameters().get("displayFormat"));
>                     date = format.parse(dateStr); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>                     return MessageFormat.format(RFC3339_PATTERN, date);
>                 } else {
>                     // last resource to assume already in correct/default format
>                     return dateStr;
>                 }
>             } catch (ParseException e) {
> -------------

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