This discussion is archived
1 Reply Latest reply: Aug 6, 2013 10:26 PM by tohkawa RSS

timezone incorrect in applet on first use when JAR's are packed

1004556 Newbie
Currently Being Moderated
We have an applet with over 100 JAR's, all of which are signed and packed with pack200. On the first use of the applet date's are showing incorrectly in GMT. We are in British Summer Time so the date/time should be an hour forward of GMT. If the user closes our application then runs it again, the date's are all correct (and are correct on all subsequent sessions).

I've added a couple of System.out's as follows:

System.out.println("Default Timezone class = " + TimeZone.getDefault().getClass().getName() + ", toString = " + TimeZone.getDefault());
System.out.println("user.timezone = " + System.getProperty("user.timezone"));

The first time the applet runs the default timezone is showing as UTC.

+Default Timezone class = sun.util.calendar.ZoneInfo, toString = sun.util.calendar.ZoneInfo[id="UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]+

user.timezone = Europe/London

The second time the applet runs the default timezone is showing as Europe/London

+Default Timezone class = sun.util.calendar.ZoneInfo, toString = sun.util.calendar.ZoneInfo[id="Europe/London",offset=0,dstSavings=3600000,useDaylight=true,transitions=242,lastRule=java.util.SimpleTimeZone[id=Europe/London,offset=0,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]+

user.timezone = Europe/London

This only occurs when the JAR's are packed using pack200. If I don't pack the JAR's the date is correct and the default timezone is always Europe/London. I can reproduce the issue by clearing the Java cache, however after the JAR's are downloaded and cached the date's are correct.

Adding the following property to the applet JNLP file seems to resolve the issue in our applet

<property name="sun.locale.formatasdefault" value="true"/>

However this does NOT fix the issue when running by WebStart. I haven't raised a bug as I haven't been able to create a simple reproducable yet. I've tried to determine if this is caused by a particular JAR but haven't been able to. When I've deployed the applet with a mixture of packed and normal JAR files the issue still occurs but only some of the time (and it doesn't seem to matter which JAR's I pack and which ones I don't).

Has anyone else experienced a problem like this? Any ideas if this is a bug?

We are running on Java 1.7.0_21.

Thanks, Rich.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points