Symbian
Symbian OS Library

FAQ-0224 Why doesn't the clock in j:\demo\clock take account of daylight saving or time zone?

[Index][spacer] [Previous] [Next]



 

Classification: Java Category: java.util
Created: 05/27/99 Modified: 12/17/2001
Number: FAQ-0224
Platform: ER5, Symbian OS v6.0, Symbian OS v6.1

Question:
The clock in the JDK demo applet included in \erj\demo\clock on the Symbian OS SDK (Java Edition) does not reflect daylight saving and/or time zone adjustments made to the system clock. Why so?

Answer:
This is a subtle problem which also affects Sun's JDK 1.1.x for Windows and applets running in various browsers. It also affects the Java Runtime on v5 of Symbian OS.
For timezone and daylight saving to be reflected in the clock, the Java VM needs dynamically to determine the relevant system settings when it is launched. This functionality was not implemented for the v5 release. If you are writing an application rather than an applet, you can work around this problem with the JNI-based ELocale utility available from http://www.symbiandevnet.com/downloads/java/files/elocale/el_desc.htm. This allows your Java application not only to pick up the system time on launch but to be kept up to date with any changes to system time which occur subsequently. This is made use of in the clock in the ToolbarFrame utility class available from http://www.symbiandevnet.com/downloads/java/files/toolbarframe/tbf_desc.htm.

This limitation is overcome in the v6 release of Symbian OS. Symbian's PersonalJava Application Environment picks up the current locale as a system property on launch. So Java applications will correctly reflect the current daylight saving and timezone settings of the host phone. They will not however pick up changes made to the system locale after the VM has been launched. This functionality could if wished be implemented using the approach employed in the ELocale class, although it should be emphaisised that the build of the native library on which that class depends is specific to v5 of Symbian OS.