United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4225280 : British Summer Time still not working

Details
Type:
Bug
Submit Date:
1999-03-30
Status:
Closed
Updated Date:
1999-08-20
Project Name:
JDK
Resolved Date:
1999-08-20
Component:
core-libs
OS:
generic,windows_95,windows_nt
Sub-Component:
java.util:i18n
CPU:
generic,other,x86
Priority:
P3
Resolution:
Duplicate
Affected Versions:
1.1.7,1.2.0,1.2.1,1.2.2
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Duplicate:

Sub Tasks

Description

Name: vi73552			Date: 03/30/99


This may be demonstrated by the following code:

///////////////////////// File T.java /////////////////////////////////
import java.util.*;


public class T
{
	public static void main(String[] args)
	{
		GregorianCalendar cal = new GregorianCalendar();
		cal.setTime(new Date());

		int	hr	= cal.get(Calendar.HOUR_OF_DAY);
		int	tzo	= cal.get(Calendar.ZONE_OFFSET)
				+ cal.get(Calendar.DST_OFFSET);
		tzo /= 3600000;      // Convert to hours.
		System.out.println("tzo = "+tzo+", hr = "+hr);
	}
}

//////////////////////// End of File ///////////////////////////////////

I have run this program with my computer's clock set to various different
timezones and dates, and everything works well, eg for Russian Standard Time
(in winter, with no daylight saving) the program gives the output:

tzo = 3, hr = <<same as system clock>>

while in summer, ie Russian Daylight Time, the output is:

tzo = 4, hr = <<same as system clock>>

Also, for Greenwich Mean Time (Britain in winter), the output is as expected:

tzo = 0, hr = <<same as system clock>>

The problem arises when I set the system clock to British Summer Time by
selecting 'Greenwich Mean Time' for the time zone and setting the calendar to
a summer month.  Then the output of the program is:

tzo = 0, hr = <<one hour less than the system clock>>

instead of the correct 'tzo = 1, hr = <<same as system clock>>'.  In other words,
the hour is the GMT hour, and the offset is the GMT offset, but this contradicts
the system clock which is showing British Summer Time.


(There seems to be a jinx on British Summer Time:  in Java 1.0 the timezone
offset returned by java.util.Date for BST was 59 minutes instead of 60 minutes!)

I hope this is helpful.  Please contact me if you want any further info.

Tom Nicholson.

Tel. 44 (0)181 473 9144  (UK)
###@###.###

java version 1.2
full version JDK-1.2-V
(Review ID: 56302) 
======================================================================

Name: krT82822			Date: 04/08/99


All Windows NT SP 4.0; In JDK 1.1.8 RC && 1.2 && 1.1.7B the TimeZone
is still unaware of British Summer Time.

This is just unacceptable, this problem has been known about for a
year and still isn't fixed even in 1.2!

A year old known bug, that will effect everyone in the UK,
managed to get through 'quality control'.
It is hardly a difficult thing to test, whats the excuse ?


Code to reproduce the problem follows, to make it work uncomment 
the static initialiser.

import java.text.DateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.SimpleTimeZone;

public class DateBug2
{
/*
  static
  {
System.out.println("TimeZone = " + TimeZone.getDefault().getID());
    if (TimeZone.getDefault().getID().equals("GMT"))
    {
      SimpleTimeZone stz = new SimpleTimeZone(0, "DCH");
      stz.setStartRule(Calendar.MARCH,-1,Calendar.SUNDAY,2*60*60*1000);
      stz.setEndRule(Calendar.OCTOBER,-1,Calendar.SUNDAY,2*60*60*1000);
      TimeZone.setDefault(stz);
    }
System.out.println("TimeZone = " + TimeZone.getDefault().getID());
  }*/ 
  static DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM);
  static Calendar cal = Calendar.getInstance(TimeZone.getDefault());
  public static void main(String[] args) throws Exception
  {
System.out.println("(Main)TimeZone = " + TimeZone.getDefault().getID());
    long currentTimeMillis;	
    long calMillis;
    if (args.length > 0)
    {
      currentTimeMillis = Long.parseLong(args[0]);	
      calMillis = Long.parseLong(args[0]);	
    }
    else		
    {
      currentTimeMillis = System.currentTimeMillis();	
      calMillis = Calendar.getInstance(TimeZone.getDefault()).getTime().getTime();
    }
    System.out.println("currentTimeMillis " + currentTimeMillis );
    System.out.println("calMillis " + calMillis );
    System.out.println("util.Date " + new java.util.Date(currentTimeMillis ) );
    System.out.println("currentTimeMillis " + df.format(new java.util.Date(currentTimeMillis )));
    System.out.println("calMillis " + df.format(new java.util.Date(currentTimeMillis )));
    System.out.println("in Daylight Savings ? " + TimeZone.getDefault().inDaylightTime(new java.util.Date(currentTimeMillis )));

  }
	
}
======================================================================

Name: krT82822			Date: 08/09/99


When obtaining the current date/time using Calendar in UK
during daylight saving (British Summer Time - BST) using
Windows NT Service Pack 4 or 5 the time is returned in GMT.
Service Pack 3 provides the date/time correctly as BST (GMT + 1).

A tame windows programmer has informed me after writing a test
program in C++ that some of Microsoft's date handling stuff has
changed between Service Pack 3 and Service Pack 4/5.
(Review ID: 93682)
======================================================================

                                    

Comments
PUBLIC COMMENTS

WinNT SP4 changes return value of GetTimeZoneInformation. New correct time zone mapping will be provided.
                                     
2004-06-10
WORK AROUND



Name: vi73552			Date: 03/30/99


To directly code for BST, note that now-a-days in Britain, the
clocks go forward 1 hour at 1am on the last Sunday of March,
and back again at 2am on the last Sunday of October.
======================================================================

Use java command line option, -Duser.timezone=Europe/London. However, since user.timezone is not publicly avaiable system property, may change in future release.
koushi.takahashi@japan 1999-07-21
                                     
1999-07-21
EVALUATION

The timezone mapping from the platform to Java is broken for some timezones. The use of the region information of Locale for this mapping is also wrong. If the locale is set to Japanese (Japan), the test program in Description works correctly.
masayoshi.okutsu@Eng 1999-07-05

The current implementation on win32 platform in kestrel to search timezone is following steps.
1. call win32 API. GetTimeZoneInformation(&tzi)
2. change win32 name to java zone name, by compare tzi.StandardName to timezone_names[] in locale_str.h.
3.1 If it found, set system property "user.timezone" to that value.
3.2 If not found, use numeric value in tzi structure, look into timezone_map[] in timezone_map.h

I guess, from NT4 SP4, GetTimeZoneInformation(&tzi) changed return value. Will try to investigate further.
koushi.takahashi@japan 1999-07-06

WindowsNT changed return value of GetTimeZoneInformation(&tzi) before and after SP4.
before SP4 (tested on SP3)
tzi.StandardName "GMT"
after SP4 install
tzi.StandardName "GMT StandardTime"
Yes, the bug exists, since current mappings on timezone_names[] in locale_str.h maps "GMT StandardTime" to java's "GMT (and win32's "GMT" to java's "Europe/London"). However, simply changes mappings will break SP3 case.
koushi.takahashi@japan 1999-07-07

The fix will be provided by time zone fix on 4252929.
koushi.takahashi@japan 1999-08-20
                                     
1999-07-07



Hardware and Software, Engineered to Work Together