X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E087232A115 for ; Fri, 15 Oct 2004 23:13:39 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88462-01 for ; Fri, 15 Oct 2004 22:13:35 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 0BB2032A07C for ; Fri, 15 Oct 2004 23:13:37 +0100 (BST) Received: (qmail 32633 invoked from network); 15 Oct 2004 22:15:02 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 15 Oct 2004 22:15:02 -0000 Message-ID: <41704B97.1050707@fastcrypt.com> Date: Fri, 15 Oct 2004 18:13:43 -0400 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 0.8 (X11/20041001) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jair da Silva Ferreira Jr Cc: Markus Schaber , pgsql-jdbc@postgresql.org Subject: Re: problem with dates when using a java calendar object with References: <416DB991.3060809@amazon.com.br> <20041014100201.761efae5@kingfisher.intern.logi-track.com> <416E9011.50908@amazon.com.br> <20041015121147.68987296@kingfisher.intern.logi-track.com> <41703CD7.3030608@amazon.com.br> In-Reply-To: <41703CD7.3030608@amazon.com.br> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/170 X-Sequence-Number: 11275 As Kris already pointed out you can use the calendar specified by the user now; if you download the development driver. Dave Jair da Silva Ferreira Jr wrote: > Hi Markus, > Thank you very much for your reply. > > Markus Schaber wrote: > >> Hi, Jair, >> >> On Thu, 14 Oct 2004 11:41:21 -0300 >> Jair da Silva Ferreira Jr wrote: >> >> >> >>> My test table definition is: create table date_test (d date) >>> As you can see it is a date type, so there's no time zone >>> information on it. >>> Do you think that the date not having time zone information is the >>> source of the problem? If yes, what time zone should I use so that >>> dates are correctly inserted and selected? UTC time zone? The >>> default JVM timezone? >>> >> >> >> It is possible that this is the source of your problem. >> >> Table columns with time zone always remember the time zone of the dates >> stored, while the table columns without time zone convert your date to >> UTC and forget the original time zone. >> >> This had to be changed at postgres level. Just test whether manually >> inserting dates (e. G. via psql) and then re-reading works. >> >> > I inserted dates via pgsql and selected them via Java and the > problem remains. I keep getting wrong days in my date. I think the > JDBC driver is somehow considering the current jvm timezone to > calculate dates. I think this is wrong because I am providing a > user-defined Calendar exactly not to use the jvm default. > I analysed the AbstractJdbc2Statement.java and > AbstractJdbc2ResultSet.java source code and I noticed that the driver > transforms the date in a String and them inserts it into the database. > Maybe the problem is how the String is being generated. I think the > best solution is to use a java.text.DateFormat object with the > calendar specified by the user set on it. This DateFormat object could > be used to both insert and select the date value from the database > because it has a format(Date) and parse(Date) method. What do you think? > > Thanks, > Jair Jr > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > -- Dave Cramer www.postgresintl.com 519 939 0336 ICQ#14675561