Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > TimeZone change - how to use TimeZone class

Reply
Thread Tools

TimeZone change - how to use TimeZone class

 
 
axrock
Guest
Posts: n/a
 
      03-20-2009
Hi,

Ok, firstly I know nothing about Java. But hoping somebody here has
got the skills to give me some pointers to fix a problem.

1. I use an application that is bundled with its own version of Java.
Problem is, the TimeZone is wrong and so to is the TZ Data.
2. I need to know how to change the TimeZone in the bundled version
from the command line. Because I then have to update about 50
computers. Command line would allow me to do it in one hit. TZupdater
is no good, as that only seems to update the system java. Not the java
our application uses.

Here is how the paths are defined.

/usr/local/javaapp/jvm/bin
java executable is in here

/usr/localjavaapp/jvm/lib
rt.jar is in here ( I notice a class in this file called TimeZone )
and figure this is the class I call to set it to what I want. Am I
correct?

I go to /usr/local/javaapp/jvm/bin and type:
../java -classpath /usr/local/javaapp/lib TimeZone=NZDT

However I get an error:
Exception in thread "main" java.lang.NoClassDefFoundError:
TimeZone=NZDT

My question is, what is the correct syntax to alter the TimeZone from
command line based on the above locations of the files?

Also, is this the way to do it, or is TimeZone class also in
another .jar file that I should be looking for?

Really appreciate your help, this is now taking me far to long to work
out and I am beginning to age trying to work it out myself.

Many thanks.
 
Reply With Quote
 
 
 
 
Joshua Cranmer
Guest
Posts: n/a
 
      03-20-2009
axrock wrote:
> I go to /usr/local/javaapp/jvm/bin and type:
> ./java -classpath /usr/local/javaapp/lib TimeZone=NZDT


What do you think that will actually do?

> My question is, what is the correct syntax to alter the TimeZone from
> command line based on the above locations of the files?


Judging from the documentation on Sun's website, this should be the
correct thing to do:

cd /usr/local/javaapp/jvm/bin;
java -jar ~/tzupdater.jar -u

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      03-21-2009
On Fri, 20 Mar 2009 14:36:58 -0700 (PDT), axrock
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone
who said :

>
>Ok, firstly I know nothing about Java. But hoping somebody here has
>got the skills to give me some pointers to fix a problem.


1. document your bug, with some proof of the anomaly (e.g. scanned
newspaper clipping) and submit it to Sun.

see http://mindprod.com/jgloss/bugs.html

These tables are a bear to keep accurate. The whole idea of DST is
insane. Trains ignore it. It causes too many anomalies. You can't
even do time sheets properly because of it.


2. You can create your own time zone objects to use is special
circumstances.

see http://mindprod.com/jgloss/timezone.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

"In the central North Pacific, plastic outweighs surface zooplankton 6 to 1."
~ Thomas M. Kostigen
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      03-21-2009
On Fri, 20 Mar 2009 14:36:58 -0700 (PDT), axrock
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone
who said :

>/usr/localjavaapp/jvm/lib


Don't screw with the standard libraries. There are many
implementations. They can too easily get updated on you undoing your
patch.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"In the central North Pacific, plastic outweighs surface zooplankton 6 to 1."
~ Thomas M. Kostigen
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      03-21-2009
axrock said:
>> I go to /usr/local/javaapp/jvm/bin and type:
>> ./java -classpath /usr/local/javaapp/lib TimeZone=NZDT
>> However I get an error:
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> TimeZone=NZDT


Roedy Green wrote:
> 1. document your bug, with some proof of the anomaly (e.g. scanned
> newspaper clipping) and submit it to Sun.


It's not a bug that invoking 'java' on something not a Java class should give
that error message. That command does not follow the rules for invocation of
the 'java' command. Just for starters, '=' is not a valid character for a
class name.

As for
>> 1. I use an application that is bundled with its own version of Java.
>> Problem is, the TimeZone is wrong and so to is the TZ Data [sic].


the OP does not tell us what version "its own version of Java" is. Possibly
it's an unpatched older version that predates some change in DST rules, or
it's got a time zone hard coded that doesn't match the OP's. It might not
even be a Sun Java, for all the OP has told us. There's just not enough
evidence in the OP's post to tell us that there's a bug in any version of
Java, much less Sun's.

> These tables are a bear to keep accurate. The whole idea of DST is
> insane. Trains ignore it. It causes too many anomalies. You can't
> even do time sheets properly because of it.


I agree with you wholeheartedly.

--
Lew
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      03-21-2009
On Fri, 20 Mar 2009 21:39:30 -0400, Lew <(E-Mail Removed)> wrote,
quoted or indirectly quoted someone who said :

>> These tables are a bear to keep accurate. The whole idea of DST is
>> insane. Trains ignore it. It causes too many anomalies. You can't
>> even do time sheets properly because of it.

>
>I agree with you wholeheartedly.


Prior to standard time, every town kept its own local time. You could
imagine the difficulty that caused once the telegraph and trains were
shrinking the world. So Sir Sandford Fleming invented standard time
zones. The boundaries have jags to suit the political realities but it
basically brought as much order to the chaos as you could reasonably
expect.

However, other people hate the order, and deliberately screwed it up
by inventing DST, with every jurisdiction deciding for itself on just
how much DST to have. We are working our way back slowly but surely
to the old system, that does not even have the uniformity of solar
synching.

The Internet is shrinking the world further. To get ahead of the
curve, perhaps we should set our watches to UTC, or at least he
alternate time function, such as I have on my desk clock.

You'd think, at least in airports clocks would also be in UTC as would
schedules. Once people got used to this, they would not be confused
by changing time zones.

It would be nice at least if there were a U.N. department of time that
maintained the official list of timezones and their DST rules. It is
a difficult job. It should not be duplicated.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Nature provides a free lunch, but only if we control our appetites."
~ William Ruckelshaus, America’s first head of the EPA
 
Reply With Quote
 
Joshua Cranmer
Guest
Posts: n/a
 
      03-21-2009
Roedy Green wrote:
> The Internet is shrinking the world further. To get ahead of the
> curve, perhaps we should set our watches to UTC, or at least he
> alternate time function, such as I have on my desk clock.


As the world gets smaller (socioeconomically speaking, of course), it
stands to reason that time would be segregated into personal time--a
time of local convenience--and official time. Certainly, if
extraplanetary or extrasolar habitations become common, such a
distinction would probably have to be enforced. But even before then,
multinational corporations and projects already have to deal with wide
disparities of time zones.

> You'd think, at least in airports clocks would also be in UTC as would
> schedules. Once people got used to this, they would not be confused
> by changing time zones.


+<however many votes I am entitled to give to a proposal>

> It would be nice at least if there were a U.N. department of time that
> maintained the official list of timezones and their DST rules. It is
> a difficult job. It should not be duplicated.


And the workers would be the Time Monks?

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      03-21-2009
Roedy Green wrote:
> Prior to standard time, every town kept its own local time. You could
> imagine the difficulty that caused once the telegraph and trains were
> shrinking the world. So Sir Sandford Fleming invented standard time
> zones. The boundaries have jags to suit the political realities but it
> basically brought as much order to the chaos as you could reasonably
> expect.
>
> However, other people hate the order, and deliberately screwed it up
> by inventing DST, with every jurisdiction deciding for itself on just
> how much DST to have. We are working our way back slowly but surely
> to the old system, that does not even have the uniformity of solar
> synching.


I don't think that is the motive.

> The Internet is shrinking the world further. To get ahead of the
> curve, perhaps we should set our watches to UTC, or at least he
> alternate time function, such as I have on my desk clock.


All UTC does have some nice characteristics.

> You'd think, at least in airports clocks would also be in UTC as would
> schedules. Once people got used to this, they would not be confused
> by changing time zones.


But I am not so sure about airport time. It is a critical
part of avoiding jet lag to start thinking in local time.

Arne
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      03-25-2009
On Sat, 21 Mar 2009 14:44:49 -0700, Roedy Green
<(E-Mail Removed)> wrote, quoted or indirectly quoted
someone who said :

>
>However, other people hate the order, and deliberately screwed it up
>by inventing DST, with every jurisdiction deciding for itself on just
>how much DST to have. We are working our way back slowly but surely
>to the old system, that does not even have the uniformity of solar
>synching.


to get an idea what a nightmare DST has created have a look at
http://java.sun.com/javase/timezones..._versions.html

To make sense of time you need a database that not only tracks what
every micro jurisdiction is doing to meddle with time, but all they
have ever done.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Don’t worry about the world coming to an end today.
It is already tomorrow in Australia."
~ Charles Schulz
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
TimeZone calculation on Windows Vista with DateTime::TimeZone Ami Perl Misc 5 09-24-2007 07:27 AM
Convert windows TimeZone to Java TimeZone asaf Java 3 09-11-2006 05:40 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Timezone Change with date::manip marcie Perl 0 04-28-2004 02:41 PM



Advertisments