diff options
author | James Moger <james.moger@gitblit.com> | 2014-11-06 19:39:11 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-11-06 23:10:42 -0500 |
commit | 9817bb2b4712e20e88f8a7803dec41d66263eb81 (patch) | |
tree | f15349c46c7bf86319217ffbe6d8043e3dd451e0 /src/main | |
parent | 09a2c37d83a2eff6bc65cdc69e8fe2869fe9709c (diff) | |
download | iciql-9817bb2b4712e20e88f8a7803dec41d66263eb81.tar.gz iciql-9817bb2b4712e20e88f8a7803dec41d66263eb81.zip |
Improve Date type conversions
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/iciql/util/Utils.java | 14 |
1 files changed, 14 insertions, 0 deletions
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)) {
|