Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 5585 invoked from network); 22 Jul 2010 21:49:14 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Jul 2010 21:49:14 -0000 Received: (qmail 93364 invoked by uid 500); 22 Jul 2010 21:49:13 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 93309 invoked by uid 500); 22 Jul 2010 21:49:13 -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: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 93302 invoked by uid 99); 22 Jul 2010 21:49:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jul 2010 21:49:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jul 2010 21:49:12 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o6MLmqVC003899 for ; Thu, 22 Jul 2010 21:48:52 GMT Message-ID: <10990377.527161279835332145.JavaMail.jira@thor> Date: Thu, 22 Jul 2010 17:48:52 -0400 (EDT) From: "Lily Wei (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-4752) CheapDateFormatter returns incorrect and invalid date strings In-Reply-To: <6650973.494891279712629887.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-4752?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12891355#action_12891355 ] Lily Wei commented on DERBY-4752: --------------------------------- I am not totally understand the performance impact for this issue. However, (280000-190000)/280000 is 32% slower. If we apply that to a big amount of timestamp implementation store procedure. Will that be a slower scenario case? > CheapDateFormatter returns incorrect and invalid date strings > ------------------------------------------------------------- > > Key: DERBY-4752 > URL: https://issues.apache.org/jira/browse/DERBY-4752 > Project: Derby > Issue Type: Bug > Components: Services > Affects Versions: 10.7.0.0 > Reporter: Knut Anders Hatlen > Assignee: Knut Anders Hatlen > Priority: Minor > Attachments: CheapFormatterPerfTest.java, derby-4752-1a.diff, derby-4752-1b.diff, derby-4752-1c.diff > > > CheapDateFormatter has multiple problems. These are the ones I'm aware of: > 1) On the boundary between non-leap years and leap years it will return first day of thirteenth month in previous year (for instance, 2011-13-01 instead of 2012-01-01) > 2) It treats all years divisible by four as leap years. Those divisible by 100 and not by 400 are not leap years. It attempts to adjust for that (see the snippet below) but it always ends up setting leapYear=true if (year%4)==0. > // It's a leap year if divisible by 4, unless divisible by 100, > // unless divisible by 400. > if ((year % 4L) == 0) { > if ((year % 100L) == 0) { > if ((year % 400L) == 0) { > leapYear = true; > } > } > leapYear = true; > } > 3) More leap year trouble. To find out which year it is, it calculates the number of four year periods that have elapsed since 1970-01-01. A four year period is considered 365*3+366 days. Although most four year periods are of that length, some are shorter, so we'll get one day off starting from year 2100, two days off from year 2200, and so on. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.