Archived:Getting the current time is timezone dependent on S60 2nd Edition (Known Issue)
hamishwillee
(Talk | contribs) m (moved Getting the current time is timezone dependent on S60 2nd Edition (Known Issue) to Archived:Getting the current time is timezone dependent on S60 2nd Edition (Known Issue)) |
|||
| (10 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | {{Archived|timestamp=20120608175031|user=[[User:Lpvalente|Lpvalente]]}} | |
| − | + | [[Category:Known Issue]][[Category:Java ME]][[Category:S60 2nd Edition (initial release)]] | |
| − | |||
| − | + | {{ArticleMetaData <!-- v1.2 --> | |
| + | |sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) --> | ||
| + | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | ||
| + | |devices= Nokia 6600 | ||
| + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> | ||
| + | |platform= S60 2nd Edition | ||
| + | |devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) --> | ||
| + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | ||
| + | |signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase --> | ||
| + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |translated-by= <!-- [[User:XXXX]] --> | ||
| + | |translated-from-title= <!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by= <!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| + | |update-by= <!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp= <!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate= 20070820 | ||
| + | |author= [[User:Technical writer 1]] | ||
| + | <!-- The following are not in current metadata --> | ||
| + | |subcategory= | ||
| + | |id= KIJ000085 | ||
| + | }} | ||
| − | CLDC 1.0 specification requires the method System.currentTimeMillis() to return the time in UTC (GMT). | + | ==Description== |
| + | {{Abstract|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. | 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. | ||
| Line 12: | Line 36: | ||
In the Nokia 6600 device such existing MIDlets might behave differently, using UTC instead of local time as expected in many use cases. | 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. | Use a Calendar object to get the local time. | ||
| − | Calendar calendar = Calendar.getInstance() ; | + | <code java> |
| + | Calendar calendar = Calendar.getInstance() ; // uses default TimeZone | ||
| + | Calendar.setTime( new Date( System.currentTimeMillis()) ; | ||
| + | </code> | ||
Note: The phone user can set the time zone as follows: | Note: The phone user can set the time zone as follows: | ||
| − | + | # By turning the automatic time update on. This is a network service and is not supported in all networks. | |
| + | # 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. | 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. | ||
| − | |||
Latest revision as of 04:55, 19 June 2012
The article is believed to be still valid for the original topic scope.
Article Metadata
Tested with
Compatibility
Article
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.
Note: The phone user can set the time zone as follows:
- By turning the automatic time update on. This is a network service and is not supported in all networks.
- 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.

