Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 22721 invoked from network); 16 Apr 2008 10:42:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Apr 2008 10:42:32 -0000 Received: (qmail 66397 invoked by uid 500); 16 Apr 2008 10:42:33 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 66379 invoked by uid 500); 16 Apr 2008 10:42:33 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 66370 invoked by uid 99); 16 Apr 2008 10:42:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Apr 2008 03:42:32 -0700 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.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Apr 2008 10:41:48 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 79AC2234C0D3 for ; Wed, 16 Apr 2008 03:39:24 -0700 (PDT) Message-ID: <79825353.1208342364496.JavaMail.jira@brutus> Date: Wed, 16 Apr 2008 03:39:24 -0700 (PDT) From: "Jim Yu (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-2422) [classlib][luni] Can not set negative value to java.util.GregorianCalendar.ZONE_OFFSET In-Reply-To: <1103678.1165237161096.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 [ https://issues.apache.org/jira/browse/HARMONY-2422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12589492#action_12589492 ] Jim Yu commented on HARMONY-2422: --------------------------------- I've just looked at this issue. Actually, If we try to set an arbitrary value to ZONE_OFFSET field, the returned value by get method will not be changed. It is a raw offset from GMT in milliseconds depends on your time zone. The reson is that, in computeFields method, ZONE_OFFSET field will always be set. According to the spec, complete method will only fills in any unset fields in the calender fields. So I think it is not correct to set ZONE_OFFSET again in computeFields method if we have set it already. We should add an if statement to judge whether the ZONE_OFFSET field has been set before setting its value. We can use isSet[ZONE_OFFSET] to determine whether the field has been set. Since when we set a field value, the associated item in isSet boolean array will be set true. I've submit my patch. > [classlib][luni] Can not set negative value to java.util.GregorianCalendar.ZONE_OFFSET > -------------------------------------------------------------------------------------- > > Key: HARMONY-2422 > URL: https://issues.apache.org/jira/browse/HARMONY-2422 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Artem Aliev > > If try to set negative value to ZONE_OFFSET field, it will be changed > to some positive value. RI doesn't have such behavior. > Probably compatibility issue. > Test to reproduce: > import junit.framework.TestCase; > import java.util.GregorianCalendar; > public class Test extends TestCase { > public void testcase() { > GregorianCalendar gc = new GregorianCalendar(1, 1, 1); > System.out.println("gc = " + gc); > gc.set(GregorianCalendar.ZONE_OFFSET, -1); > System.out.println("gc.get(" + GregorianCalendar.ZONE_OFFSET + ") = " + > gc.get(GregorianCalendar.ZONE_OFFSET)); > assertTrue("gc.get(" + GregorianCalendar.ZONE_OFFSET + ") == -1", > (gc.get(GregorianCalendar.ZONE_OFFSET) == -1)); > } > } > Output on Harmony: > Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software > Foundation or its licensors, as applicable. > java version "1.5.0" > pre-alpha : not complete or compatible > svn = rsvn: '.' is not a working copy, (Sep 20 2006), Windows/ia32/msvc 1310, > release build > http://incubator.apache.org/harmony > .gc = > java.util.GregorianCalendar[time=?,areFieldsSet=false,lenient=true,zone=java.util.SimpleTimeZone[id=Asia/Novosibirsk,offset=21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=7200000,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=7200000],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA==?,YEAR==1,MONTH==1,WEEK_OF_YEAR==?,WEEK_OF_MONTH==?,DAY_OF_MONTH==1,DAY_OF_YEAR==?,DAY_OF_WEEK==?,DAY_OF_WEEK_IN_MONTH==?,AM_PM==?,HOUR==?,HOUR_OF_DAY=?,MINUTE==?,SECOND==?,MILLISECOND==?,ZONE_OFFSET==?,DST_OFFSET==?] > gc.get(15) = 21600000 > F > Time: 0.078 > There was 1 failure: > 1) testcase(Test)junit.framework.AssertionFailedError: gc.get(15) == -1 > at Test.testcase(Test.java:12) > at java.lang.reflect.VMReflection.invokeMethod(Native Method) > FAILURES!!! > Tests run: 1, Failures: 1, Errors: 0 > res = 1 > Output on RI: > java version "1.5.0_06" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) > Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode) > .gc = > java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Novosibirsk",offset=21600000,dstSavings=3600000,useDaylight=true,transitions=119,lastRule=java.util.SimpleTimeZone[id=Asia/Novosibirsk,offset=21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=7200000,startTimeMode=1,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=1]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=1,MONTH=1,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=1,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=?,ZONE_OFFSET=?,DST_OFFSET=?] > gc.get(15) = -1 > Time: 0.016 > OK (1 test) > res = 0 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.