Daylight detection fails in Java 1.1.8

W

work

Hi,

When I execute this following program in a windows PC with timezone is set
to GMT + 0 ( London) with automatic adjust for daylight saving enabled, I
get different results for java version 1.1.8 and 1.4.3.
In version 1.1.8 , the useDaylightTime() returns false which is wrong. In
version 1.4.3 , it returns true which is correct.
Similarly the getDisplayName() is not working in 1.1.8 but works in 1.4.3.
Could any body help me in how to achieve correct result for
daylightdetection for this timezone using version 1.1.8.

Here is the sample program.

import java.util.*;
public class timezone{
public static void main(String[] args) {

TimeZone tzone = TimeZone.getDefault();
//String tzn = tzone.getDisplayName(); // Not working
in 1.1.8
//System.out.println(tzn);
if (tzone.useDaylightTime())
System.out.println("Daylight time present");
else
System.out.println("Daylight time absent");
}
}

Thanks/Regards,
Work.
 
P

P.Hill

work said:
Hi,

When I execute this following program in a windows PC with timezone is set
to GMT + 0 ( London) with automatic adjust for daylight saving enabled,

And what are the cutover dates for DLS in the timezone definition in
the JDK for the "GMT" TZ? There were some bugs in this in earlier versions of
the JDK, because the authors did what you are doing -- assuming GMT is the name
of pair of times winter and summer that occurs in/around London.
GMT should be No DLS even if you turn on its use. You want to use a TZ that
actually has DLS, not the name abbrevaiation for a time which doesn't have DLS.

-Paul
 
R

Roedy Green

And what are the cutover dates for DLS in the timezone definition in
the JDK for the "GMT" TZ? There were some bugs in this in earlier versions of
the JDK, because the authors did what you are doing -- assuming GMT is the name
of pair of times winter and summer that occurs in/around London.
GMT should be No DLS even if you turn on its use. You want to use a TZ that
actually has DLS, not the name abbrevaiation for a time which doesn't have DLS.

to see a list of TimeZones and what they mean, see
http://mindprod.com/jgloss/timezone.html


You need Java installed. :)
 
P

P.Hill

Roedy said:
to see a list of TimeZones and what they mean, see
http://mindprod.com/jgloss/timezone.html

I didn't have a second to look it up yesterday, but Roedy's list
quickly shows us the difference between:
0.0 (1.0) Europe/London
0.0 GMT

GMT, as it should, has no DLS while Europe/London
follows the civil rules in effect in London.

The problem is that Timezones can be defined as simply a particular
offset from zero. That is the usage when someones says that
Arizona (which doesn't have any summer DLS time) is in the
Mountain time zone in the winter Pacific timezone in summer. This is
common usage but is not particular useful for a computer system.

In many systems including Unix and in Java, a timezone is defined
as the set of offsets valid in a particular location, because a machine
is in some location. Arizona does not move timezones under this usage,
it has it own algorithm for winter/summer; that is, the offset from GMT is
the same in summer and winter. That is why there is a "US/Arizona"
timezone defined in Java.

There is rarely any official name given to pair of summer/winter offsets,
that is why those detectives/reporters that compile timezone information
use a region name followed by a large city as the name for a timezone.
People in the middle of the United States can be said to be in the same timezone
as Chicago, eastern Australia follows the same rules as Sydney etc.

London is not in the GMT 'timezone', GMT defines an offset, London
uses two offsets one in summer one in winter. The winter one
is named GMT.

I hope that helps,
-Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top