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