BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-25-2008, 05:46 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Oct 2007
Model: 7100i
PIN: N/A
Carrier: Dont know
Posts: 195
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting local time into GMT time and then to milliseconds

Please Login to Remove!

Hi

In my application i get the current time(with local time zone) of the blackberry convert it into GMT time using calendar class, now i want to convert this GMT time into milliseconds; but whenever i convert this GMT calendar into milliseconds then it gives the milliseconds which is same as the number of milliseconds of the current time(local time zone).

Does anyone have any idea how we can convert the local time with local time zone into milliseconds of the GMT ?

Thanks in advance..
Offline  
Old 11-25-2008, 07:18 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

System.currentTimeMillis() returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

In casual use, Greenwich Mean Time (GMT) is the same as UTC and UT1
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 11-25-2008, 11:54 PM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Oct 2007
Model: 7100i
PIN: N/A
Carrier: Dont know
Posts: 195
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply simon,

but i am not very clear can you please explain me little bit how can i exactly get GMT time of my local time in milliseconds.
The main problem is i converted the GMT into milliseconds as below:
Code:
Date _date = new Date();
long currentTime = _date.getTime();
TimeZone _timeZone = TimeZone.getDefault();
Calendar _calendar = Calendar.getInstance();
int gmtOffset = _timeZone.getOffset(1, _calendar.get(Calendar.YEAR), _calendar.get(Calendar.MONTH), _calendar.get(Calendar.DATE), _calendar.get(Calendar.DAY_OF_WEEK), _calendar.get(Calendar.MILLISECOND));
System.out.println("GMT Time as Long: " + currentTime - gmtOffset);
it gives the correct GMT millis i guess so, but when is send it to the server and compares the server's time in millis(which is converted into GMT) the difference is very large (while it should not be greater than a 10000 millis), so i am really confused whether the conversion is wrong or there is some other problem.

Plz do share if u have any ideas.

Thanks once again.
Offline  
Closed Thread


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

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

MSA Altair 5X, Calibrated, New Accessories
$599.99
MSA Altair 5X, Calibrated, New Accessories pictureMSA Altair 4x Multi Gas 10107602 Detector O2 CO H2S LEL Warranty Calibrated
$445.0
MSA Altair 4x Multi Gas 10107602 Detector O2 CO H2S LEL Warranty Calibrated pictureMsa H2S Altair Pro Single Gas Detector,Calibration Cert Included,Glow-n-Dark
$54.99
Msa H2S Altair Pro Single Gas Detector,Calibration Cert Included,Glow-n-Dark pictureMsa Altair Inlet Dust Filters 5 Pack, 808935
$3.49
Msa Altair Inlet Dust Filters 5 Pack, 808935 pictureNEW MSA 10042621 Sampling Probe For Use With ALTAIR Multi-Gas Detector
$99.99
NEW MSA 10042621 Sampling Probe For Use With ALTAIR Multi-Gas Detector picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.