Please run
Also, when I run
I get
Greenwich Mean Time
GB
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Originally posted by James Sabre:
Also, when I run
I get
Greenwich Mean Time
GB
It is interesting that when I run that code on Windows XP SP3 using 1.6.0_07 I get
Greenwich Mean Time
Europe/London
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
So if my System in configured to be in say XYZ timezone, I wish my Java code to be able to print this XYZ timezone.
What is the command for this? I am using Java 1.4.2.
Thanks,
Diksha
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
----------------
TimeZone tz = Calendar.getInstance().getTimeZone();
System.out.println(tz.getDisplayName());// (i.e. Moscow Standard Time)
System.out.println(tz.getID());
-----------------
and for me the output was
---------------------
India Standard Time
Asia/Calcutta
---------------------
then i went back and changed the time zone to Singapor and got the followng output
----------------------
Singapore Time
Asia/Singapore
----------------------
it is taking the time zone dynamically and shownig it so where is your problem?
one more thing i added following line of code
System.out.println(tz.getTimeZone(tz.getID()));//will this help ?
[ October 24, 2008: Message edited by: Tanu Gulati ]
[ October 24, 2008: Message edited by: Tanu Gulati ]
thanks
Tanu Gulati
http://binodjava.blogspot.com/2009/05/how-to-get-other-timezone-time-by-java.html
Thanks,
Binod Suman
http://binodsuman.blogspot.com
jittu goud wrote:i had issues with this previously....
![]()
when i run the
its prints GMT for me...
output
Greenwich Mean Time
Europe/London
09:50:07
but if i use simpledateformat...it prints correct ,,,
its prints the right time and time zone for me ...![]()
output---Thu May 14 21:50:07 BST 2009
Sorry for late reply.................
In order to get the short timezone like "BST" you could use the code below

/etc/localtime used to be a symlink in GNU/Linux a long time ago, and apparently Java still has code to handle /etc/localtime as a symlink

So from a sitation like this:
If you somehow ran this command:
This would overwrite /usr/share/zoneinfo/Europe/Paris with UTC information, effectively changing the system timezone to UTC for all applications except JVM-based ones!
