Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf7b89ac

Browse files
author
Peter Mount
committed
Some more getTimestamp() fixes
1 parentd3f6552 commitf7b89ac

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

‎src/interfaces/jdbc/CHANGELOG

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
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+
16
Tue 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

1822
Thu Jul 20 16:30:00 BST 2000 petermount@it.maidstone.gov.uk
1923
- Fixed DatabaseMetaData.getTableTypes()

‎src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,23 @@ public Timestamp getTimestamp(int columnIndex) throws SQLException
462462
if(s==null)
463463
returnnull;
464464

465-
SimpleDateFormatdf =newSimpleDateFormat("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+
SimpleDateFormatdf =null;
471+
if (s.length()>21 &&s.indexOf('.') != -1) {
472+
df =newSimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSzzz");
473+
}elseif (s.length()>19 &&s.indexOf('.') == -1) {
474+
df =newSimpleDateFormat("yyyy-MM-dd HH:MM:sszzz");
475+
}elseif (s.length()>19 &&s.indexOf('.') != -1) {
476+
df =newSimpleDateFormat("yyyy-MM-dd HH:MM:ss.SS");
477+
}elseif (s.length()>10 &&s.length()<=18) {
478+
df =newSimpleDateFormat("yyyy-MM-dd HH:MM:ss");
479+
}else {
480+
df =newSimpleDateFormat("yyyy-MM-dd");
481+
}
466482

467483
try {
468484
returnnewTimestamp(df.parse(s).getTime());

‎src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,23 @@ public Timestamp getTimestamp(int columnIndex) throws SQLException
465465
if(s==null)
466466
returnnull;
467467

468-
SimpleDateFormatdf =newSimpleDateFormat("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+
SimpleDateFormatdf =null;
474+
if (s.length()>21 &&s.indexOf('.') != -1) {
475+
df =newSimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSzzz");
476+
}elseif (s.length()>19 &&s.indexOf('.') == -1) {
477+
df =newSimpleDateFormat("yyyy-MM-dd HH:MM:sszzz");
478+
}elseif (s.length()>19 &&s.indexOf('.') != -1) {
479+
df =newSimpleDateFormat("yyyy-MM-dd HH:MM:ss.SS");
480+
}elseif (s.length()>10 &&s.length()<=18) {
481+
df =newSimpleDateFormat("yyyy-MM-dd HH:MM:ss");
482+
}else {
483+
df =newSimpleDateFormat("yyyy-MM-dd");
484+
}
469485

470486
try {
471487
returnnewTimestamp(df.parse(s).getTime());

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp