[PATCH 2 of 4] Add timestamp type

Wald Commits scm-commit at wald.intevation.org
Thu Nov 21 15:40:10 CET 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1385044532 -3600
# Node ID c2acc840963b77b0c354596b11a1660d46a60b22
# Parent  fab06617afb2276d8791a816d019e66e15aec03f
Add timestamp type

diff -r fab06617afb2 -r c2acc840963b artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/TypeConverter.java
--- 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;


More information about the Dive4elements-commits mailing list