Operating System - HP-UX
1834020 Members
2712 Online
110063 Solutions
New Discussion

How to get rigth time in Java running on HP-UX?

 
SOLVED
Go to solution
Lorin Mizrahi
New Member

How to get rigth time in Java running on HP-UX?

We are running Weblogic 8.1 SP4 ( using Java Hotspot JDK 1.4.2-05 )on HP-UX 11.0.
The Java has problems returning the rigth time when summertime daylight saving is on ( in winter is OK... ). There is ONE hour difference between real time and java system time ). There are no such problems on other UNIX OS , e.g. Sun Solaris.
How I can get the rigth time , without sofisticated workarounds , when using Java processes on HP-UX.
Thank you in advance
6 REPLIES 6
Mel Burslan
Honored Contributor

Re: How to get rigth time in Java running on HP-UX?

whe you are in the unix command prompt, do you have the same problem, i.e. is the system ignoring the daylight savings time when you siiue the

date

command ? If so, your /etc/TIMEZONE file may have a problem. As an example, mine looks this way and and I am on the west coast of USA

# cat /etc/TIMEZONE
TZ=PST8PDT
export TZ
________________________________
UNIX because I majored in cryptology...
Lorin Mizrahi
New Member

Re: How to get rigth time in Java running on HP-UX?

I have written a short script,time_test.sh:

echo Time from HP-UX shell:
date
echo "***********"
java -classpath /users/mis107/user/dev/weblogic Test

The content of the class Test.java is the following:

import java.util.Date;
public class Test{
public static void test(){
System.out.println("Time from java program :"+new Date());
}
public static final void main(String[] args) {
test();
}
}



Here is the output of the script

mis107-weblogic #time_test.sh
Time from HP-UX shell:
Tue Aug 1 18:28:01 IDT 2006
***********
Time from java program :Tue Aug 01 17:28:02 GMT+02:00 2006


Please notice the ONE hour difference ( I don't care about the one second difference )
spex
Honored Contributor
Solution

Re: How to get rigth time in Java running on HP-UX?

Lorin,

"What's your time zone?
Get a handle on Java date and time classes" might prove useful:

http://www.javaworld.com/javaworld/jw-10-2003/jw-1003-time.html

PCS
Steven E. Protter
Exalted Contributor

Re: How to get rigth time in Java running on HP-UX?

Shalom Lorin,

Make sure your system gets the right time and Java is properly patched. That really should be the end of it.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Lorin Mizrahi
New Member

Re: How to get rigth time in Java running on HP-UX?

Thank you - the solution posted in the link (see above) it works!

Run Java using JVM parameter -Duser.timezone with the suitable time zone. For a list with available time zones see this link :

http://publib.boulder.ibm.com/infocenter/wsdoc400/v6r0/index.jsp?topic=/com.ibm.websphere.iseries.doc/info/ae/ae/adrtzval.htm
Lorin Mizrahi
New Member

Re: How to get rigth time in Java running on HP-UX?

As mentioned above - see the solution