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