]> source.dussan.org Git - iciql.git/commitdiff
Improve Date type conversions
authorJames Moger <james.moger@gitblit.com>
Fri, 7 Nov 2014 00:39:11 +0000 (19:39 -0500)
committerJames Moger <james.moger@gitblit.com>
Fri, 7 Nov 2014 04:10:42 +0000 (23:10 -0500)
src/main/java/com/iciql/util/Utils.java

index e542054b0c4ace63fb49504268c8c5f6e3714691..346c6d791c8a766fc46dbd7a86d368a09c579d3a 100644 (file)
@@ -31,6 +31,7 @@ import java.util.ArrayList;
 import java.util.Arrays;\r
 import java.util.Collection;\r
 import java.util.Collections;\r
+import java.util.Date;\r
 import java.util.HashMap;\r
 import java.util.HashSet;\r
 import java.util.IdentityHashMap;\r
@@ -320,6 +321,19 @@ public class Utils {
                        }\r
                }\r
 \r
+               if (Date.class.isAssignableFrom(currentType)) {\r
+                       Date d = (Date) o;\r
+                       if (targetType == Date.class) {\r
+                               return o;\r
+                       } else if (targetType == java.sql.Date.class) {\r
+                               return new java.sql.Date(d.getTime());\r
+                       } else if (targetType == java.sql.Time.class) {\r
+                               return new java.sql.Time(d.getTime());\r
+                       } else if (targetType == java.sql.Timestamp.class) {\r
+                               return new java.sql.Timestamp(d.getTime());\r
+                       }\r
+               }\r
+\r
                // convert from BLOB\r
                if (targetType == byte[].class) {\r
                        if (Blob.class.isAssignableFrom(currentType)) {\r