aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/jdbc/CHANGELOG6
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java18
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java18
3 files changed, 39 insertions, 3 deletions
diff --git a/src/interfaces/jdbc/CHANGELOG b/src/interfaces/jdbc/CHANGELOG
index 84eebc6577b..e61acd7df93 100644
--- a/src/interfaces/jdbc/CHANGELOG
+++ b/src/interfaces/jdbc/CHANGELOG
@@ -1,3 +1,8 @@
+Tue Oct 17 15:35:00 BST 2000 petermount@maidstone.gov.uk
+ - Changed getTimestamp() again. This time Michael Stephenson's
+ <mstephenson@tirin.openworld.co.uk> solution looked far better
+ than the original solution put in June.
+
Tue Oct 10 13:12:00 BST 2000 peter@retep.org.uk
- DatabaseMetaData.supportsAlterTableWithDropColumn() as psql doesn't
support dropping of individual columns
@@ -13,7 +18,6 @@ Mon Sep 25 14:22:00 BST 2000 peter@retep.org.uk
- Removed the DriverClass kludge. Now the org.postgresql.Driver class
is compiled from a template file, and now has both the connection
class (ie jdbc1/jdbc2) and the current version's from Makefile.global
- -
Thu Jul 20 16:30:00 BST 2000 petermount@it.maidstone.gov.uk
- Fixed DatabaseMetaData.getTableTypes()
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
index e65cf80b55b..e9fc53d96a8 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
@@ -462,7 +462,23 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
if(s==null)
return null;
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ // This works, but it's commented out because Michael Stephenson's
+ // solution is better still:
+ //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ // Michael Stephenson's solution:
+ SimpleDateFormat df = null;
+ if (s.length()>21 && s.indexOf('.') != -1) {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSzzz");
+ } else if (s.length()>19 && s.indexOf('.') == -1) {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:MM:sszzz");
+ } else if (s.length()>19 && s.indexOf('.') != -1) {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss.SS");
+ } else if (s.length()>10 && s.length()<=18) {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss");
+ } else {
+ df = new SimpleDateFormat("yyyy-MM-dd");
+ }
try {
return new Timestamp(df.parse(s).getTime());
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
index 5c73b6ed4f0..e606a16785d 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
@@ -465,7 +465,23 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
if(s==null)
return null;
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ // This works, but it's commented out because Michael Stephenson's
+ // solution is better still:
+ //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ // Michael Stephenson's solution:
+ SimpleDateFormat df = null;
+ if (s.length()>21 && s.indexOf('.') != -1) {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSzzz");
+ } else if (s.length()>19 && s.indexOf('.') == -1) {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:MM:sszzz");
+ } else if (s.length()>19 && s.indexOf('.') != -1) {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss.SS");
+ } else if (s.length()>10 && s.length()<=18) {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss");
+ } else {
+ df = new SimpleDateFormat("yyyy-MM-dd");
+ }
try {
return new Timestamp(df.parse(s).getTime());