changeset 7592:c2acc840963b

Add timestamp type
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 21 Nov 2013 15:35:32 +0100
parents fab06617afb2
children 60a5fc522ec4
files artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/TypeConverter.java
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/TypeConverter.java	Thu Nov 21 15:33:42 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/TypeConverter.java	Thu Nov 21 15:35:32 2013 +0100
@@ -8,7 +8,8 @@
 
 package org.dive4elements.river.artifacts.datacage.templating;
 
-import java.util.Date;
+import java.sql.Date;
+import java.sql.Timestamp;
 
 import org.apache.log4j.Logger;
 
@@ -52,6 +53,19 @@
             }
         }
 
+        if ("timestamp".equals(type)) {
+            if (object instanceof Timestamp) {
+                return object;
+            }
+            try {
+                return new Timestamp((long)Double.parseDouble(object.toString()));
+            }
+            catch (NumberFormatException nfe) {
+                log.warn(nfe);
+                return null;
+            }
+        }
+
         // TODO: Add more types
 
         return object;

http://dive4elements.wald.intevation.org