summaryrefslogtreecommitdiffstats
path: root/databases/postgresql92-server/files/patch-jdbc-getdate
blob: 744407ae14b5ffe6794aaba25a617a5c745d191f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--- src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java~	Fri Feb 23 19:12:23 2001
+++ src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java	Wed May  9 04:31:11 2001
@@ -423,8 +423,13 @@
     String s = getString(columnIndex);
     if(s==null)
       return null;
-
-    return java.sql.Date.valueOf(s);
+    // length == 10: SQL Date
+    // length >  10: SQL Timestamp, assumes PGDATESTYLE=ISO
+    try {
+      return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0,10));
+    } catch (NumberFormatException e) {
+      throw new PSQLException("postgresql.res.baddate", s);
+    }
   }
 
   /**
@@ -441,8 +446,13 @@
 
     if(s==null)
       return null; // SQL NULL
-
-    return java.sql.Time.valueOf(s);
+    // length == 8: SQL Time
+    // length >  8: SQL Timestamp
+    try {
+      return java.sql.Time.valueOf((s.length() == 8) ? s : s.substring(11,19));
+    } catch (NumberFormatException e) {
+      throw new PSQLException("postgresql.res.badtime",s);
+    }
   }
 
   /**
OpenPOWER on IntegriCloud