Some more getTimestamp() fixes

REL7_1_STABLE
Peter Mount 26 years ago
parent d3f6552821
commit f7b89ac5d9
  1. 6
      src/interfaces/jdbc/CHANGELOG
  2. 18
      src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
  3. 18
      src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

@ -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()

@ -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());

@ -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());

Loading…
Cancel
Save