daylight savings not shown properly in Timezone.getDefault()

H

Hariharan.A

Hi,

I am facing a problem in TimeZone.getDefault(). Running the given program
returns different results in Linux. The jdk version is 1.4

import java.util.*;
public class Test
{
public static void main(String [] args)
{
System.out.println(TimeZone.getDefault());
TimeZone tz = TimeZone.getDefault();
System.out.println(tz.useDaylightTime());
}
}

For Pacific Timezone.

$java Test
java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=
3600
000,useDaylight=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDa
yOfW
eek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDa
yOfW
eek=1,endTime=7200000,endTimeMode=0]
true

When I give the timezone in command line then the day light setting is not
getting set..

$java -Duser.timezone=GMT-800 Test
java.util.SimpleTimeZone[id=Custom,offset=-28800000,dstSavings=3600000,useDa
ylig
ht=false,startYear=0,startMode=0,startMonth=0,startDay=0,startDayOfWeek=0,st
artT
ime=0,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0
,end
TimeMode=0]
false

Any idea how to over come this. If I use "user.region" instead of
"user.timezone" then it says daylight is enabled. But for Asian time on
giving "user.region" the offset is returned as zero.

For Asian Timezone.

$java Test
sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,
transitions=0,lastRule=null]
false
$java -Duser.region=Asia/NewDelhi Test
sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,
transitions=0,lastRule=null]
false

$java -Duser.timezone=GMT+530 Test
sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDa
ylight=false,transitions=0,lastRule=null]
false

Thanks,
- Hari
 

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,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top