From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21934 invoked by alias); 25 Oct 2002 18:26:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 21840 invoked by uid 71); 25 Oct 2002 18:26:01 -0000 Date: Fri, 25 Oct 2002 11:26:00 -0000 Message-ID: <20021025182601.21839.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: dongfeng@spinnakernet.com Subject: java/8321: SimpleTimeZone doesn't work properly for daylight saving time. Reply-To: dongfeng@spinnakernet.com X-SW-Source: 2002-10/txt/msg01024.txt.bz2 List-Id: The following reply was made to PR java/8321; it has been noted by GNATS. From: dongfeng@spinnakernet.com To: gcc-gnats@gcc.gnu.org Cc: Subject: java/8321: SimpleTimeZone doesn't work properly for daylight saving time. Date: Wed, 23 Oct 2002 10:44:00 -0400 >Number: 8321 >Category: java >Synopsis: SimpleTimeZone doesn't work properly for daylight saving time. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Oct 23 07:46:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: >Release: 3.1 >Organization: >Environment: System: Linux build2 2.4.9-12 #1 Tue Oct 30 18:33:49 EST 2001 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc/configure --host=i686-pc-linux-gnu --prefix=/home/dongfeng/gcc/temp --enable-shared --enable-threads=posix --enable-languages=c,c++,java --enable-version-specific-runtime-libs >Description: When I ran the folllowing code Date date = new Date(1034705556525l); TimeZone zone = TimeZone.getTimeZone("EST"); DateFormat dateFormat = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.LONG, Locale.getDefault()); dateFormat.setTimeZone(zone); System.out.println(dateFormat.format(new Date())); I got 10/15/2002 1:12:36 AM EST but I expected 10/15/2002 2:12:36 AM EDT because 10/23 is still in daylight saving time. I checked the code of SimpleTimeZone.java. The function setEndRule changes endDay to its absolute value that is wrong in this case. The time zone instance for EST is new SimpleTimeZone (-5000 * 3600, "EST", Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600, Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600); that has endDay -1. Turning -1 to 1 changes the end date of daylight saving time from the last Sunday to the first Sunday in October. The same thing happens for setStartRule. After removing the Math.abs from the code, I got the time I want. >How-To-Repeat: Run above code. >Fix: For setStartRule, change to this.startDay = day; this.startDayOfWeek = dayOfWeek; For setEndRule,change to this.endDay = day; this.endDayOfWeek = dayOfWeek; >Release-Note: >Audit-Trail: >Unformatted: