File tree Expand file tree Collapse file tree 3 files changed +39
-3
lines changed Expand file tree Collapse file tree 3 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 1+ Tue Oct 17 15:35:00 BST 2000 petermount@maidstone.gov.uk
2+ - Changed getTimestamp() again. This time Michael Stephenson's
3+ <mstephenson@tirin.openworld.co.uk> solution looked far better
4+ than the original solution put in June.
5+
16Tue Oct 10 13:12:00 BST 2000 peter@retep.org.uk
27 - DatabaseMetaData.supportsAlterTableWithDropColumn() as psql doesn't
38 support dropping of individual columns
@@ -13,7 +18,6 @@ Mon Sep 25 14:22:00 BST 2000 peter@retep.org.uk
1318 - Removed the DriverClass kludge. Now the org.postgresql.Driver class
1419 is compiled from a template file, and now has both the connection
1520 class (ie jdbc1/jdbc2) and the current version's from Makefile.global
16- -
1721
1822Thu Jul 20 16:30:00 BST 2000 petermount@it.maidstone.gov.uk
1923 - Fixed DatabaseMetaData.getTableTypes()
Original file line number Diff line number Diff line change @@ -462,7 +462,23 @@ public Timestamp getTimestamp(int columnIndex) throws SQLException
462462 if (s ==null )
463463 return null ;
464464
465- SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss" );
465+ // This works, but it's commented out because Michael Stephenson's
466+ // solution is better still:
467+ //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
468+
469+ // Michael Stephenson's solution:
470+ SimpleDateFormat df = null ;
471+ if (s .length ()>21 && s .indexOf ('.' ) != -1 ) {
472+ df = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSzzz" );
473+ } else if (s .length ()>19 && s .indexOf ('.' ) == -1 ) {
474+ df = new SimpleDateFormat ("yyyy-MM-dd HH:MM:sszzz" );
475+ } else if (s .length ()>19 && s .indexOf ('.' ) != -1 ) {
476+ df = new SimpleDateFormat ("yyyy-MM-dd HH:MM:ss.SS" );
477+ } else if (s .length ()>10 && s .length ()<=18 ) {
478+ df = new SimpleDateFormat ("yyyy-MM-dd HH:MM:ss" );
479+ } else {
480+ df = new SimpleDateFormat ("yyyy-MM-dd" );
481+ }
466482
467483 try {
468484 return new Timestamp (df .parse (s ).getTime ());
Original file line number Diff line number Diff line change @@ -465,7 +465,23 @@ public Timestamp getTimestamp(int columnIndex) throws SQLException
465465 if (s ==null )
466466 return null ;
467467
468- SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss" );
468+ // This works, but it's commented out because Michael Stephenson's
469+ // solution is better still:
470+ //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
471+
472+ // Michael Stephenson's solution:
473+ SimpleDateFormat df = null ;
474+ if (s .length ()>21 && s .indexOf ('.' ) != -1 ) {
475+ df = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSzzz" );
476+ } else if (s .length ()>19 && s .indexOf ('.' ) == -1 ) {
477+ df = new SimpleDateFormat ("yyyy-MM-dd HH:MM:sszzz" );
478+ } else if (s .length ()>19 && s .indexOf ('.' ) != -1 ) {
479+ df = new SimpleDateFormat ("yyyy-MM-dd HH:MM:ss.SS" );
480+ } else if (s .length ()>10 && s .length ()<=18 ) {
481+ df = new SimpleDateFormat ("yyyy-MM-dd HH:MM:ss" );
482+ } else {
483+ df = new SimpleDateFormat ("yyyy-MM-dd" );
484+ }
469485
470486 try {
471487 return new Timestamp (df .parse (s ).getTime ());
You can’t perform that action at this time.
0 commit comments