This page was last modified 10:14, 23 August 2007.
KIJ000085 - Getting the current time takes the TimeZone into account
From Forum Nokia Wiki
Platform: S60 2nd Edition Device: Nokia 6600
Description:
CLDC 1.0 specification requires the method System.currentTimeMillis() to return the time in UTC (GMT).
Because some earlier phone models supported only time zone UTC, MIDlet programmers did not always take the difference between UTC and local time into account. MIDlets did work correctly assuming that the returned value was in local time, without even checking time zone settings.
In the Nokia 6600 device such existing MIDlets might behave differently, using UTC instead of local time as expected in many use cases.
Solution:
Use a Calendar object to get the local time.
Calendar calendar = Calendar.getInstance() ; // uses default TimeZone
Calendar.setTime( new Date( System.currentTimeMillis()) ;
Note: The phone user can set the time zone as follows:
1. By turning the automatic time update on. This is a network service and is not supported in all networks.
2. By setting the time zone manually in the Clock application or under Settings / Date & Time.
MIDlet programmers should be aware that Java applications are just about the only application in the phone that uses the time zone. Thus, users might have incorrect time zone settings in their phone without being aware of it.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| installe netbeans_documentation_setup.exe | stein | Mobile Java Tools & SDKs | 3 | 2008-03-06 20:59 |
| What happened to gsmu.lib in the Series 60 SDK | torsen | Symbian Tools & SDKs | 3 | 2004-05-07 10:18 |
| How is System.currentTimeMillis() implemented in Nokia's devices? | Nokia_FAQ | Mobile Java General | 1 | 2002-05-13 19:44 |
| Carbide.c++ Developer 1.1 - the missing features | jimgilmour1 | Tools and SDK Feedback | 15 | 2006-09-29 15:22 |
| How can I get the time of the SMS being sent? | jliun | General Messaging | 5 | 2006-02-08 06:07 |

