DateConvert(日期类型转换器)

public class DateConvert extends StrutsTypeConverter {


    /* (non-Javadoc)
     * @see org.apache.struts2.util.StrutsTypeConverter#convertFromString(java.util.Map, java.lang.String[], java.lang.Class)
     */
    @Override
    public Object convertFromString(Map arg0, String[] dates, Class arg2) {
       // TODO Auto-generated method stub
       if(dates[0]==null||dates[0].equals("")){
           return null;
       }
       Timestamp date=DateFormatTool.string2TimeStamp(dates[0]);
       return date;
    }


    /* (non-Javadoc)
     * @see org.apache.struts2.util.StrutsTypeConverter#convertToString(java.util.Map, java.lang.Object)
     */
    @Override
    public String convertToString(Map arg0, Object date) {
       // TODO Auto-generated method stub
       String dateStr=DateFormatTool.timestamp2String((Timestamp)date);
       return dateStr;
    }


}

你可能感兴趣的:(java,apache)