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()); }}