Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 92509 invoked from network); 14 Jan 2005 01:22:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 14 Jan 2005 01:22:38 -0000 Received: (qmail 19472 invoked by uid 500); 14 Jan 2005 01:22:37 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 19251 invoked by uid 500); 14 Jan 2005 01:22:37 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: List-Id: Reply-To: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 19236 invoked by uid 99); 14 Jan 2005 01:22:37 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from i.meepzor.com (HELO Boron.MeepZor.Com) (204.146.167.214) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 13 Jan 2005 17:22:35 -0800 Received: from [9.30.40.133] (dmz-firewall [206.199.198.4]) by Boron.MeepZor.Com (8.12.8/8.12.8) with ESMTP id j0E1MZwE023451 for ; Thu, 13 Jan 2005 20:22:36 -0500 Message-ID: <41E71EE5.8020809@golux.com> Date: Thu, 13 Jan 2005 17:22:45 -0800 From: Army User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Development Subject: Date formatting with Network Server Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Question regarding date formatting in the Network Server: System.out.println(java.sql.Date.valueOf("0001-01-01")); With a Sun JVM, the above line will print "0001-01-01". With an IBM JVM, it will print "1-01-01". The difference is apparently in the implementation of the "toString()" method for the two JVMs. Currently, when a query against Network Server returns a date column, the string value for that column is returned using the following line (in DRDAConnThread.java): writer.writeString(((java.sql.Date) val).toString()); This works fine for Sun JVM, because the toString() method returns "0001-01-01". However, for IBM JVM, the string "1-01-01" is returned, and that causes the JDBC client to fail, presumably because the client sees it as an invalid date string. This is reproduced easily enough; start the server with an IBM JVM, connect to it using ij, insert the value "0001-01-01" into a table, then select from the table. You'll get an error. So my question is three-fold: 1) The Java definition for java.sql.Date.toString() says: "Formats a date in the date escape format yyyy-mm-dd". So as far as I can tell, this means that, with the current implementation, the format yyyy-mm-dd will always be used, regardless of locale. Is that right? And is that _acceptable_?? 2) If the answer to #1 is "Yes", then is it safe to replace the "writeString" call above with the following? SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd"); writer.writeString(df.format((java.sql.Date) val)); Or is there some reason why we need to avoid using SimpleDateFormat? 3) I noticed some DateFormat code in the engn, for Derby embedded. Should Network Server just be using that somehow, instead of doing a different thing here? Feedback/input? Thanks, Army