LongConvert(Long类型转换器)

public class LongConvert extends StrutsTypeConverter {


    /*
     * (non-Javadoc)
     * @see org.apache.struts2.util.StrutsTypeConverter#convertFromString(java.util.Map, java.lang.String[], java.lang.Class)
     */
    @SuppressWarnings("unchecked")
    @Override
    public Object convertFromString(Map context, String[] values, Class toClass) {
       Long num = 0l;
       try {
           num = Long.valueOf(values[0]);
       } catch (Exception e) {
           num = 0l;
       }
       return num;
    }


    /*
     * (non-Javadoc)
     * @see org.apache.struts2.util.StrutsTypeConverter#convertToString(java.util.Map, java.lang.Object)
     */
    @SuppressWarnings("unchecked")
    @Override
    public String convertToString(Map context, Object o) {
       String num = o.toString();
       return num;
    }


}

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