public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: dongfeng@spinnakernet.com
To: gcc-gnats@gcc.gnu.org
Subject: java/8321: SimpleTimeZone doesn't work properly for daylight saving time.
Date: Wed, 23 Oct 2002 07:46:00 -0000	[thread overview]
Message-ID: <200210231444.g9NEi0617807@build2.spinnakernet.com> (raw)


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


             reply	other threads:[~2002-10-23 14:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-23  7:46 dongfeng [this message]
2002-10-25 11:26 dongfeng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200210231444.g9NEi0617807@build2.spinnakernet.com \
    --to=dongfeng@spinnakernet.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).