diff options
author | Dave Cramer <davec@fastcrypt.com> | 2002-03-05 03:29:30 +0000 |
---|---|---|
committer | Dave Cramer <davec@fastcrypt.com> | 2002-03-05 03:29:30 +0000 |
commit | 8f83590aa18ed5416b094225fe46b1e0611569e3 (patch) | |
tree | fa6405156c221b6e15f1e3aad4f3af20269f16ea /src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java | |
parent | 7aa6270fc7ac60b8a7ef1364a40d67636e735af0 (diff) | |
download | postgresql-8f83590aa18ed5416b094225fe46b1e0611569e3.tar.gz |
Patch from Ryouichi Matsuda
An attached patch corrects problem of this bug and fractional second.
The handling of time zone was as follows:
(a) with time zone
using SimpleDateFormat("yyyy-MM-dd HH:mm:ss z")
(b) without time zone
using SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
About problem of fractional second,
Fractional second was changed from milli-second to nano-second
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java')
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java index c5cf5619bb..949b919541 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java @@ -514,7 +514,9 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu StringBuffer sbuf = new StringBuffer(s); SimpleDateFormat df = null; - if (s.length() > 19) + int slen = s.length(); + + if (slen > 19) { // The len of the ISO string to the second value is 19 chars. If // greater then 19, there should be tz info and perhaps fractional @@ -534,7 +536,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu if (i < 24) sbuf.append(c); c = s.charAt(i++); - } while (Character.isDigit(c)); + } while (i < slen && Character.isDigit(c)); // If there wasn't at least 3 digits we should add some zeros // to make up the 3 digits we tell java to expect. @@ -547,21 +549,28 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu sbuf.append(".000"); } - // prepend the GMT part and then add the remaining bit of - // the string. - sbuf.append(" GMT"); - sbuf.append(c); - sbuf.append(s.substring(i, s.length())); - - // Lastly, if the tz part doesn't specify the :MM part then - // we add ":00" for java. - if (s.length() - i < 5) - sbuf.append(":00"); - - // we'll use this dateformat string to parse the result. - df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z"); + if (i < slen) + { + // prepend the GMT part and then add the remaining bit of + // the string. + sbuf.append(" GMT"); + sbuf.append(c); + sbuf.append(s.substring(i, slen)); + + // Lastly, if the tz part doesn't specify the :MM part then + // we add ":00" for java. + if (slen - i < 5) + sbuf.append(":00"); + + // we'll use this dateformat string to parse the result. + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z"); + } + else + { + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + } } - else if (s.length() == 19) + else if (slen == 19) { // No tz or fractional second info. // I'm not sure if it is |