From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Jan Thomae <jan(at)smb-tec(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: My Bug report: JDBC-Driver produces wrong output.] |
Date: | 2000-11-04 16:38:48 |
Message-ID: | 200011041638.LAA22508@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
I think this is fixed in the current cvs tree. Can you grab a snapshot
ftp file and let me know. If not, can I get a contect diff. Thanks.
> Hi,
>
> I had a look over the JDBC-Driver and was able to remove the bug. It seems,
> that the formatting of the timestamp caused the malfunction. I'd like to send
> you my modifications, since you might be interested in them:
>
> File: ResultSet.java
> Directory: src/interfaces/jdbc/org/postgresql/jdbc2
>
> public Timestamp getTimestamp(int columnIndex) throws SQLException
> {
> String s = getString(columnIndex);
>
> if(s==null)
> return null;
>
> // 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");
>
> // Modification by Jan Thomae
> String sub = s.substring(s.length() - 3, s.length()-2);
> if (sub.equals("+") || sub.equals("-")) {
> s = s.substring(0, s.length()-3) + "GMT"+ s.substring(s.length()-3, s.length())+":00";
> }
> // -------
> // Michael Stephenson's solution:
> SimpleDateFormat df = null;
>
> // Modification by Jan Thomae
> if (s.length()>27) {
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzzzzzzzz");
> } else
> // -------
> 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());
> } catch(ParseException e) {
> throw new PSQLException("postgresql.res.badtimestamp",new Integer(e.getErrorOffset()),s);
> }
> }
>
> Best regards,
> Jan Thomae
>
> --
> ____________________________________________________________________
> Jan Thomae jan(at)smb-tec(dot)com
> SMB GmbH http://www.smb-tec.com
>
>
>
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-11-04 17:26:56 | Re: AbortTransaction errors - remedy? |
Previous Message | Max Pyziur | 2000-11-04 15:27:09 | AbortTransaction errors - remedy? |