1 3 package jodd.typeconverter; 4 5 8 public class LongConverter implements TypeConverter { 9 10 public static Long valueOf(Object value) { 11 12 if (value == null) { 13 return null; 14 } 15 if (value instanceof Long ) { 16 return (Long ) value; 17 } 18 if (value instanceof Number ) { 19 return new Long (((Number )value).longValue()); 20 } 21 try { 22 return (new Long (value.toString())); 23 } catch (NumberFormatException nfex) { 24 throw new TypeConversionException(nfex); 25 } 26 } 27 28 public Object convert(Object value) { 29 return valueOf(value); 30 } 31 32 } 33 | Popular Tags |