1 3 package jodd.typeconverter; 4 5 import java.sql.Timestamp ; 6 7 10 public class SqlTimestampConverter implements TypeConverter { 11 12 13 public static Timestamp valueOf(Object value) { 14 if (value == null) { 15 return null; 16 } 17 if (value instanceof Timestamp ) { 18 return (Timestamp ) value; 19 } 20 if (value instanceof Number ) { 21 return new Timestamp (((Number )value).longValue()); 22 } 23 try { 24 return (Timestamp.valueOf(value.toString())); 25 } catch (IllegalArgumentException iaex) { 26 throw new TypeConversionException(iaex); 27 } 28 } 29 30 public Object convert(Object value) { 31 return valueOf(value); 32 } 33 34 35 } 36 | Popular Tags |