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.

Reply via email to