From: James Moger Date: Fri, 7 Nov 2014 00:39:11 +0000 (-0500) Subject: Improve Date type conversions X-Git-Tag: v1.5.0~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9817bb2b4712e20e88f8a7803dec41d66263eb81;p=iciql.git Improve Date type conversions --- diff --git a/src/main/java/com/iciql/util/Utils.java b/src/main/java/com/iciql/util/Utils.java index e542054..346c6d7 100644 --- a/src/main/java/com/iciql/util/Utils.java +++ b/src/main/java/com/iciql/util/Utils.java @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.IdentityHashMap; @@ -320,6 +321,19 @@ public class Utils { } } + if (Date.class.isAssignableFrom(currentType)) { + Date d = (Date) o; + if (targetType == Date.class) { + return o; + } else if (targetType == java.sql.Date.class) { + return new java.sql.Date(d.getTime()); + } else if (targetType == java.sql.Time.class) { + return new java.sql.Time(d.getTime()); + } else if (targetType == java.sql.Timestamp.class) { + return new java.sql.Timestamp(d.getTime()); + } + } + // convert from BLOB if (targetType == byte[].class) { if (Blob.class.isAssignableFrom(currentType)) {