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

Commit0380765

Browse files
committed
Attached is a patch to fix the problem Thomas mentions below. The JDBC
driver now correctly handles timezones that are offset fractional hoursfrom GMT (ie. -06:30).Barry Lind
1 parent9a61532 commit0380765

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,35 @@ public Timestamp getTimestamp(int columnIndex) throws SQLException
472472
//so this code strips off timezone info and adds on the GMT+/-...
473473
//as well as adds a third digit for partial seconds if necessary
474474
StringBufferstrBuf =newStringBuffer(s);
475+
476+
//we are looking to see if the backend has appended on a timezone.
477+
//currently postgresql will return +/-HH:MM or +/-HH for timezone offset
478+
//(i.e. -06, or +06:30, note the expectation of the leading zero for the
479+
//hours, and the use of the : for delimiter between hours and minutes)
480+
//if the backend ISO format changes in the future this code will
481+
//need to be changed as well
475482
charsub =strBuf.charAt(strBuf.length()-3);
476483
if (sub =='+' ||sub =='-') {
477484
strBuf.setLength(strBuf.length()-3);
478485
if (subsecond) {
479-
strBuf =strBuf.append('0').append("GMT").append(s.substring(s.length()-3,s.length())).append(":00");
486+
strBuf.append('0').append("GMT").append(s.substring(s.length()-3,s.length())).append(":00");
487+
}else {
488+
strBuf.append("GMT").append(s.substring(s.length()-3,s.length())).append(":00");
489+
}
490+
}elseif (sub ==':') {
491+
//we may have found timezone info of format +/-HH:MM, or there is no
492+
//timezone info at all and this is the : preceding the seconds
493+
charsub2 =strBuf.charAt(strBuf.length()-5);
494+
if (sub2 =='+' ||sub2 =='-') {
495+
//we have found timezone info of format +/-HH:MM
496+
strBuf.setLength(strBuf.length()-5);
497+
if (subsecond) {
498+
strBuf.append('0').append("GMT").append(s.substring(s.length()-5));
480499
}else {
481-
strBuf =strBuf.append("GMT").append(s.substring(s.length()-3,s.length())).append(":00");
500+
strBuf.append("GMT").append(s.substring(s.length()-5));
501+
}
502+
}elseif (subsecond) {
503+
strBuf.append('0');
482504
}
483505
}elseif (subsecond) {
484506
strBuf =strBuf.append('0');

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,36 @@ public Timestamp getTimestamp(int columnIndex) throws SQLException
484484
sbuf.setLength(0);
485485
sbuf.append(s);
486486

487+
//we are looking to see if the backend has appended on a timezone.
488+
//currently postgresql will return +/-HH:MM or +/-HH for timezone offset
489+
//(i.e. -06, or +06:30, note the expectation of the leading zero for the
490+
//hours, and the use of the : for delimiter between hours and minutes)
491+
//if the backend ISO format changes in the future this code will
492+
//need to be changed as well
487493
charsub =sbuf.charAt(sbuf.length()-3);
488494
if (sub =='+' ||sub =='-') {
495+
//we have found timezone info of format +/-HH
489496
sbuf.setLength(sbuf.length()-3);
490497
if (subsecond) {
491498
sbuf.append('0').append("GMT").append(s.substring(s.length()-3)).append(":00");
492499
}else {
493500
sbuf.append("GMT").append(s.substring(s.length()-3)).append(":00");
494501
}
502+
}elseif (sub ==':') {
503+
//we may have found timezone info of format +/-HH:MM, or there is no
504+
//timezone info at all and this is the : preceding the seconds
505+
charsub2 =sbuf.charAt(sbuf.length()-5);
506+
if (sub2 =='+' ||sub2 =='-') {
507+
//we have found timezone info of format +/-HH:MM
508+
sbuf.setLength(sbuf.length()-5);
509+
if (subsecond) {
510+
sbuf.append('0').append("GMT").append(s.substring(s.length()-5));
511+
}else {
512+
sbuf.append("GMT").append(s.substring(s.length()-5));
513+
}
514+
}elseif (subsecond) {
515+
sbuf.append('0');
516+
}
495517
}elseif (subsecond) {
496518
sbuf.append('0');
497519
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp