changeset 5784:efbbfe32e9fe

Fix dateFormat for Oracle by invoking dateValue on demand Oracle does not return a date object but a oracle.sql.TIMESTAMP object when querying a date. We now convert to a java date by inviking the method dateValue if it is available.
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 22 Apr 2013 16:18:16 +0200
parents 153456f84602
children d38004f0c52f
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java	Mon Apr 22 13:00:13 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java	Mon Apr 22 16:18:16 2013 +0200
@@ -7,6 +7,9 @@
 import java.util.List;
 import java.util.Map;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 import javax.xml.namespace.QName;
 
 import javax.xml.xpath.XPathFunction;
@@ -297,6 +300,16 @@
     public Object dateFormat(List args) throws XPathFunctionException {
         Object pattern = args.get(0);
         Object date    = args.get(1);
+
+        try {
+            // Oracle does not return a date object but an oracle.sql.TIMESTAMP
+            Method meth = date.getClass().getMethod("dateValue", new Class[] {});
+            date = meth.invoke(date, new Object [] {});
+        } catch (IllegalArgumentException e) {
+        } catch (IllegalAccessException e) {
+        } catch (InvocationTargetException e) {
+        } catch (NoSuchMethodException e) {
+        }
         if (pattern instanceof String && date instanceof Date) {
             try {
                 // TODO: Take locale into account.

http://dive4elements.wald.intevation.org