Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Code time-sensitive applications

by Retired ‎02-12-2010 02:46 PM - edited ‎02-17-2010 09:39 AM (1,921 Views)

Summary


This article applies to the BlackBerry® wireless devices based on Java™.




Description


Calculating Time on the Device


The time on the BlackBerry device is calculated since midnight, January 1, 1970 Universal Time Coordinate (UTC) with absolute time as milliseconds. Time on the device is typically measured in either CPU ticks or milliseconds.


Handling System Time Zone Changes


If you are caching a time-sensitive object for performance reasons, remember that the system time zone can change on the device. When the time zone changes, the system sends out a global event message to the applications. To catch it, implement the GlobalEventListener interface and register the listener by calling Application.addGlobalEventListener(). Your eventOccurred() method should look similar to this:



public void eventOccurred
(
long guid,
int data0,
int data1,
Object object0,
Object object1
){
if(guid == DateTime.GUID_TIMEZONE_CHANGED) {
_cal.setTimeZone(TimeZone.getDefault());
}
}


Contributors
Users Online
Currently online: 45 members 3,788 guests
Please welcome our newest community members: