public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/8321: SimpleTimeZone doesn't work properly for daylight saving time.
@ 2002-10-23  7:46 dongfeng
  0 siblings, 0 replies; 2+ messages in thread
From: dongfeng @ 2002-10-23  7:46 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* java/8321: SimpleTimeZone doesn't work properly for daylight saving time.
@ 2002-10-25 11:26 dongfeng
  0 siblings, 0 replies; 2+ messages in thread
From: dongfeng @ 2002-10-25 11:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-25 18:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-23  7:46 java/8321: SimpleTimeZone doesn't work properly for daylight saving time dongfeng
2002-10-25 11:26 dongfeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).