FileDocCategorySizeDatePackage
DateConverter.javaAPI DocApache Struts 2.0.9 Apps2094Mon Jul 23 13:43:26 BST 2007org.apache.struts2.showcase.chat

DateConverter

public class DateConverter extends org.apache.struts2.util.StrutsTypeConverter

Fields Summary
private static final Log
_log
Constructors Summary
Methods Summary
public java.lang.ObjectconvertFromString(java.util.Map context, java.lang.String[] values, java.lang.Class toClass)


            

        if (values.length > 0 && values[0] != null && values[0].trim().length() > 0) {
            SimpleDateFormat sdf = new SimpleDateFormat();
            try {
                return sdf.parse(values[0]);
            }
            catch(ParseException e) {
                _log.error("error converting value ["+values[0]+"] to Date ", e);
            }
        }
        return null;
    
public java.lang.StringconvertToString(java.util.Map context, java.lang.Object o)


        if (o instanceof Date) {
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
            return sdf.format((Date) o);
        }
        return "";