What is the default timezone in java.util.Date -


if create new date() object. default timezone print.

i have machine running in gmt. , creating new date() object. if print why shows thu jul 05 08:21:05 pkt 2012. how takes timezone pkt ?

the date doesn't have time zone. tostring() method uses current default time zone return string representing date:

date date = new date();  system.out.println(timezone.getdefault()); system.out.println(date);  timezone.setdefault(timezone.gettimezone("utc"));  system.out.println(timezone.getdefault()); system.out.println(date); 

executing above code on machine leads following output:

sun.util.calendar.zoneinfo[id="europe/paris",offset=3600000,dstsavings=3600000,usedaylight=true,transitions=184,lastrule=java.util.simpletimezone[id=europe/paris,offset=3600000,dstsavings=3600000,usedaylight=true,startyear=0,startmode=2,startmonth=2,startday=-1,startdayofweek=1,starttime=3600000,starttimemode=2,endmode=2,endmonth=9,endday=-1,enddayofweek=1,endtime=3600000,endtimemode=2]] fri jul 06 09:24:45 cest 2012 sun.util.calendar.zoneinfo[id="utc",offset=0,dstsavings=0,usedaylight=false,transitions=0,lastrule=null] fri jul 06 07:24:45 utc 2012 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -