1 package jodd.bean.converters; 2 3 6 public final class LongConverter implements jodd.bean.Converter { 7 8 public Object convert(Object value) throws IllegalArgumentException { 9 10 if (value == null) { 11 return (Long) null; 12 } 13 14 if (value instanceof Long) { 15 return (value); 16 } else if (value instanceof Long) { 17 return new Long(((Number)value).longValue()); 18 } 19 try { 20 return (new Long(value.toString())); 21 } catch (Exception e) { 22 throw new IllegalArgumentException("Long conversion for " + value + " failed."); 23 } 24 } 25 } 26 | Popular Tags |