Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > System.currentTimeMillis not returning GMT/UTC (J2me)

Reply
Thread Tools

System.currentTimeMillis not returning GMT/UTC (J2me)

 
 
Nelson
Guest
Posts: n/a
 
      05-13-2004
I've got an application that I built for the Motorola i730
MIDP2.0 platform. System.currentTimeMillis() always seems
to return me -as stated- in GMT/UTC. I ported the application
to run against the i88s phone MIDP1.0 and the same method
is returning me the time in the Local Time.
Is this a know issue, or am I going about this the wrong
way? It would be so bad getting the local time, but it appears
that TimeZone.getDefault().getID() is returning GMT !
Any ideas?
Thanks.
 
Reply With Quote
 
 
 
 
P.Hill
Guest
Posts: n/a
 
      05-13-2004
Nelson wrote:
> I've got an application that I built for the Motorola i730
> MIDP2.0 platform. System.currentTimeMillis() always seems
> to return me -as stated- in GMT/UTC. I ported the application
> to run against the i88s phone MIDP1.0 and the same method
> is returning me the time in the Local Time.


So how do you know that the currentTimeMillis is local time?
I don't know about you, but I wouldn't recognize milliseconds since 1970
if it bit me, so I'm guess you are doing something with it and
that processing is picking up a TZ from somewhere.
Are you using a SimpleDateFormat object to create a formatted data/time?
Could you show us example code.

-Paul

 
Reply With Quote
 
 
 
 
Mark A. Washburn
Guest
Posts: n/a
 
      05-14-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Nelson) wrote in message news:<(E-Mail Removed). com>...
> I've got an application that I built for the Motorola i730
> MIDP2.0 platform. System.currentTimeMillis() always seems
> to return me -as stated- in GMT/UTC. I ported the application
> to run against the i88s phone MIDP1.0 and the same method
> is returning me the time in the Local Time.
> Is this a know issue, or am I going about this the wrong
> way? It would be so bad getting the local time, but it appears
> that TimeZone.getDefault().getID() is returning GMT !
> Any ideas?
> Thanks.


Maybe the simplest solution is, appove an adjustment of the
application or system model to fit an additional machineTypeId
configuration parameter,
preform an application boot check,
maw
 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      05-14-2004
Nelson wrote:
> I've got an application that I built for the Motorola i730
> MIDP2.0 platform. System.currentTimeMillis() always seems
> to return me -as stated- in GMT/UTC. I ported the application
> to run against the i88s phone MIDP1.0 and the same method
> is returning me the time in the Local Time.
> Is this a know issue, or am I going about this the wrong
> way? It would be so bad getting the local time, but it appears
> that TimeZone.getDefault().getID() is returning GMT !


Sounds like the device thinks it's in GMT. Since the device doesn't
know its time zone, it would then be absolutely impossible to get that
information from anywhere else, unless you're connected to some remote
device that might know.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
Darryl L. Pierce
Guest
Posts: n/a
 
      05-15-2004
Nelson wrote:

> I've got an application that I built for the Motorola i730
> MIDP2.0 platform. System.currentTimeMillis() always seems
> to return me -as stated- in GMT/UTC. I ported the application
> to run against the i88s phone MIDP1.0 and the same method
> is returning me the time in the Local Time.
> Is this a know issue, or am I going about this the wrong
> way? It would be so bad getting the local time, but it appears
> that TimeZone.getDefault().getID() is returning GMT !


If the device isn't aware of its timezone, then there's no way for you to
determine from within the device that same information. Have you checked to
make sure that you i730's operating system is configured with the right
timezone? What is the difference between what your MIDlet thinks the time
is and what the phone states the time is from the main screen?

Also, have you checked what the java.util.Date class claims the local
date/time is when you create an instance using new Date()? Forget what
System.currentTimeMillis() returns if you can get the proper information
from Date.

--
/**
* @author Darryl L. Pierce <(E-Mail Removed)>
* @see The J2ME FAQ <http://mypage.org/mcpierce/j2mefaq.html>
* @quote "What do you care what others think, Mr. Feynman?"
* @geek echo '$_ = "Jvtu bopuifs Pfsm ibdlfs."; y/a-z/za-y/; print' |
perl
*/
 
Reply With Quote
 
Darryl L. Pierce
Guest
Posts: n/a
 
      05-15-2004
P.Hill wrote:

>> I've got an application that I built for the Motorola i730
>> MIDP2.0 platform. System.currentTimeMillis() always seems
>> to return me -as stated- in GMT/UTC. I ported the application
>> to run against the i88s phone MIDP1.0 and the same method
>> is returning me the time in the Local Time.

>
> So how do you know that the currentTimeMillis is local time?
> I don't know about you, but I wouldn't recognize milliseconds since 1970
> if it bit me, so I'm guess you are doing something with it and
> that processing is picking up a TZ from somewhere.
> Are you using a SimpleDateFormat object to create a formatted data/time?
> Could you show us example code.


The MIDP doesn't have SimpleDateFormat.

--
/**
* @author Darryl L. Pierce <(E-Mail Removed)>
* @see The J2ME FAQ <http://mypage.org/mcpierce/j2mefaq.html>
* @quote "What do you care what others think, Mr. Feynman?"
* @geek echo '$_ = "Jvtu bopuifs Pfsm ibdlfs."; y/a-z/za-y/; print' |
perl
*/
 
Reply With Quote
 
P.Hill
Guest
Posts: n/a
 
      05-15-2004
Darryl L. Pierce wrote:
> The MIDP doesn't have SimpleDateFormat.


Hm, curious. That begs the questions of how the OP knew
what the time was that he had. I assume there is some
similar class.

-Paul

 
Reply With Quote
 
P.Hill
Guest
Posts: n/a
 
      05-15-2004
Darryl L. Pierce wrote:

> Also, have you checked what the java.util.Date class claims the local
> date/time is when you create an instance using new Date()? Forget what
> System.currentTimeMillis() returns if you can get the proper information
> from Date.


The value of the two are exactly the same on a full size JDK. The Date
constructor gets its time from currentTimeMillis.

-Paul

 
Reply With Quote
 
Darryl L. Pierce
Guest
Posts: n/a
 
      05-17-2004
P.Hill wrote:

>> Also, have you checked what the java.util.Date class claims the local
>> date/time is when you create an instance using new Date()? Forget what
>> System.currentTimeMillis() returns if you can get the proper information
>> from Date.

>
> The value of the two are exactly the same on a full size JDK. The Date
> constructor gets its time from currentTimeMillis.


The Javadoc for System.currentTimeMillis() states that it returns
"the specified number of milliseconds since the standard base time
known as 'the epoch', namely January 1, 1970, 00:00:00 GMT." One should
not be expecting System.currentTimeMillis() to return the _local_ time.
The Date constructor takes the current time from System.currentTimeMillis()
and then uses your timezone to convert that value to the local time.
So, it's inaccurate to claim that System.currentTimeMillis() and Date
return the same value unless your locale *is* GMT.

--
/**
* @author Darryl L. Pierce <(E-Mail Removed)>
* @see The J2ME FAQ <http://mypage.org/mcpierce/j2mefaq.html>
* @quote "What do you care what others think, Mr. Feynman?"
* @geek echo '$_ = "Jvtu bopuifs Pfsm ibdlfs."; y/a-z/za-y/; print' |
perl
*/
 
Reply With Quote
 
Darryl L. Pierce
Guest
Posts: n/a
 
      05-17-2004
P.Hill wrote:

> Darryl L. Pierce wrote:
>> The MIDP doesn't have SimpleDateFormat.

>
> Hm, curious. That begs the questions of how the OP knew
> what the time was that he had. I assume there is some
> similar class.


You have java.util.Date available, with the default constructor creating a
Date object with the current date/time.

--
/**
* @author Darryl L. Pierce <(E-Mail Removed)>
* @see The J2ME FAQ <http://mypage.org/mcpierce/j2mefaq.html>
* @quote "What do you care what others think, Mr. Feynman?"
* @geek echo '$_ = "Jvtu bopuifs Pfsm ibdlfs."; y/a-z/za-y/; print' |
perl
*/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
g++ does not complain when not returning form non-void saneman C++ 2 10-23-2007 07:54 PM
returning none when it should be returning a list? randomtalk@gmail.com Python 11 05-02-2006 10:26 AM
Listbox Control Not Returning Selected Values Matthew Sajdera ASP .Net 1 04-12-2004 09:10 PM
Worker Thread not running and is returning a status of stopped!!! Jim Macbeth ASP .Net 3 11-10-2003 09:34 AM
HttpBrowserCapabilities not returning correct netscape version Earl T ASP .Net 4 10-15-2003 02:34 PM



Advertisments