troubleshooting Question

Java time on iSeries?

Avatar of mhaave
mhaaveFlag for Norway asked on
IBM System iJava
2 Comments1 Solution902 ViewsLast Modified:
Hello

I have a problem getting Java programs on iSeries to return the right time. The time is always wrong with an hour or two.
The following system values are set:
QTIME set to current true time.
QTIMZON set to QP0100UTCS.
Added line in SystemDefault.properties: user.timezone=Europe/Oslo

I have created a simple test program (code attached) which I run, and it prints the following:
Display name:  Central European Time
Display name DST: Central European Summer Time
DST offset:  3600000
ID: Europe/Oslo
Offset today: 7200000
Raw offset: 3600000
Current date: Mon Oct 12 13:58:19 CEST 2009
Locale: norsk (Norge)    (Norway)

Current Date is wrong by one hour. Java reports one hour later than real time. We are in Norway, and the offset should be 1 hour, and it is summertime. When running the same program on a PC, regardless of TimeZone, it always works. What am I missing?? All our RPG and CL programs work fine with dates and times.
Btw: We are using Java version 1.5.0, Classic VM build 1.5.0_13-b05)
public class TimeCheck
{
	public static void main(String[] args)
	{
		final TimeZone zone = TimeZone.getDefault();
		System.out.println("Display name:           " + zone.getDisplayName());
		System.out.println("Display name DST=false: " + zone.getDisplayName(false, TimeZone.LONG));
		System.out.println("Display name DST=true:  " + zone.getDisplayName(true, TimeZone.LONG));
		System.out.println("DST offset:             " + zone.getDSTSavings());
		System.out.println("ID:                     " + zone.getID());
		System.out.println("Offset today:           " + zone.getOffset(System.currentTimeMillis()));
		System.out.println("Raw offset:             " + zone.getRawOffset());
		System.out.println("Current time in millis: " + System.currentTimeMillis());
		System.out.println("Dato:                   " + new Date().toString());
		System.out.println("Locale:                 " + Locale.getDefault().getDisplayName());
		
	}
}
ASKER CERTIFIED SOLUTION
Gary Patterson, CISSP
Expert for hire: IBM i, AIX, Linux, Windows, DB2, Performance, Security. EDI

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros