Need Systerm Property user.timezone to be manipulated

M

Megha Vishwanath

Hi,

A jdk installation on my machine has picked up the time zone
Asia/Rangoon

My time zone is actually Asia/ Calcutta

Apparently, j2sdk1.4.2_05 does not even support Asia/Rangoon- MMT that
gets set by default to GMT.
ie., TimeZone tz=TimeZone.getTimeZone(MMT); tz.getDisplayName() is GMT

I have been trying to manipulate the timezone by setting the
user.timezone system property through this piece of code-

--------------------------------------------------------------------------------
Calendar cal = Calendar.getInstance();

System.out.println("\n TIME ZONE :"+
cal.getTimeZone().getDisplayName());
System.out.println("\n TIME :"+ cal.getTime().toGMTString());
System.out.println("\n user.timezone:
"+System.getProperty("user.timezone"));
System.out.println("\n user.country:
"+System.getProperty("user.country"));
System.out.println("\njava.home: "+System.getProperty("java.home"));

System.setProperty("user.timezone","Asia/Calcutta");


System.out.println("\nuser.timezone:
"+System.getProperty("user.timezone"));
System.out.println("\n New Time Zone:
"+TimeZone.getDefault().getDisplayName());

--------------------------------------------------------------------------------
The user.timezone only temporarily gets set only for the lifetime of
the program.
How can I permanantly change this value on my Linux Installation of
J2SDK1.4.2_05? Please help.

-Thanks
Megha.
 
T

Thomas Kellerer

Hi,

A jdk installation on my machine has picked up the time zone
Asia/Rangoon

My time zone is actually Asia/ Calcutta

Apparently, j2sdk1.4.2_05 does not even support Asia/Rangoon- MMT that
gets set by default to GMT.
ie., TimeZone tz=TimeZone.getTimeZone(MMT); tz.getDisplayName() is GMT
[...]
How can I permanantly change this value on my Linux Installation of
J2SDK1.4.2_05? Please help.

Did you try to edit <jdkhome>/jre/lib/tzmappings

Thomas
 
G

Gordon Beaton

A jdk installation on my machine has picked up the time zone
Asia/Rangoon

My time zone is actually Asia/ Calcutta

Apparently, j2sdk1.4.2_05 does not even support Asia/Rangoon- MMT
that gets set by default to GMT. ie., TimeZone
tz=TimeZone.getTimeZone(MMT); tz.getDisplayName() is GMT
[...]

The user.timezone only temporarily gets set only for the lifetime of
the program. How can I permanantly change this value on my Linux
Installation of J2SDK1.4.2_05? Please help.

Except when user.timezone is set, the JVM gets the timezone like any
other program: it checks the value of TZ (environment variable) and
failing that, uses the system default timezone.

You could write a simple wrapper for java that either sets TZ or
passes on -Duser.timezone to the "real" java program:

#!/bin/sh
TZ=Asia/Calcutta
export TZ
exec /usr/local/j2sdk1.4.2_05/bin/java "$@"

Or you could change the system default if it's wrong. The system
timezone is determined by the contents of /etc/localtime, which is
usually a copy of (or a symbolic link to) one of the files under
/usr/share/zoneinfo.

I notice that both Asia/Calcutta and Asia/Rangoon are supported by my
j2sdk1.4.2_05 on Linux, where they are reported as "India Standard
Time" and "Myanmar Time" respectively, so I don't really understand
your claim that the latter isn't supported.

Note too that the use of three letter timezone abbreviations such as
"MMT" is deprecated, which may be why your system reports "GMT" for
that.

/gordon
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top