KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jodd > bean > converters > SqlTimeConverter


1 package jodd.bean.converters;
2
3 import java.sql.Time;
4
5 /**
6  * Converts given object to java.sql.Time.
7  */

8 public final class SqlTimeConverter implements jodd.bean.Converter {
9
10     public Object convert(Object value) {
11
12         if (value == null) {
13             return (Time) null;
14         }
15         if (value instanceof Time) {
16             return value;
17         }
18
19         try {
20             return (Time.valueOf(value.toString()));
21         } catch (Exception e) {
22             throw new IllegalArgumentException("SqlTime conversion for " + value + " failed.");
23         }
24     }
25
26 }
27
Popular Tags