Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 35827 invoked from network); 17 Aug 2006 18:34:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Aug 2006 18:34:13 -0000 Received: (qmail 45952 invoked by uid 500); 17 Aug 2006 18:34:13 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 45907 invoked by uid 500); 17 Aug 2006 18:34:13 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 45896 invoked by uid 99); 17 Aug 2006 18:34:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 11:34:13 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 11:34:12 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 37FE77142B7 for ; Thu, 17 Aug 2006 18:31:15 +0000 (GMT) Message-ID: <10820230.1155839475226.JavaMail.jira@brutus> Date: Thu, 17 Aug 2006 11:31:15 -0700 (PDT) From: "Tim Ellison (JIRA)" To: harmony-commits@incubator.apache.org Subject: [jira] Resolved: (HARMONY-923) Incorrect dates in java.util.Calendar() when year is very large In-Reply-To: <33446381.1153314553924.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/HARMONY-923?page=all ] Tim Ellison resolved HARMONY-923. --------------------------------- Resolution: Fixed Thanks Anton. Patch applied to LUNI modulke at repo revision r432324. Please check it was applied as expected. > Incorrect dates in java.util.Calendar() when year is very large > --------------------------------------------------------------- > > Key: HARMONY-923 > URL: http://issues.apache.org/jira/browse/HARMONY-923 > Project: Harmony > Issue Type: Bug > Components: Classlib > Environment: Windows XP professional > Reporter: Anton Luht > Assigned To: Tim Ellison > Priority: Minor > Attachments: patch.txt > > > VM + classlib revision 423073 > Problem: with large values of year (aroung Integer.MIN_VALUE and Integer.MAX_VALUE) dates returned by Calendar diff from RI. The following test case shows it: > import java.util.*; > public class Test { > public static void main (String[] args) { > Calendar cal = Calendar.getInstance(); > int year = Integer.MIN_VALUE + 71; > cal.setTimeZone(TimeZone.getTimeZone("GMT")); > cal.set(Calendar.YEAR, year + 1900); > cal.set(Calendar.MONTH, Calendar.JANUARY); > cal.set(Calendar.DATE, 1); > cal.set(Calendar.HOUR_OF_DAY, 0); > cal.set(Calendar.MINUTE, 0); > cal.set(Calendar.SECOND, 0); > cal.set(Calendar.MILLISECOND, 0); > System.out.println(cal.getTimeInMillis()); > } > } > Output in RI: > 6017546357372606464 > Output in Harmony: > 61................................ > The problem is that though private method of GregorianCalendar daysFromBaseYear(int year) returns long, its argument is int and things like 'year - 1970' can cause int overflow. The solution is to cast argument to long and use it in further calculations. > Please see the patch with JUnit test and fix for GregorianCalendar code attached -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira