BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-26-2006, 07:38 PM   #1
phil_doyle
Knows Where the Search Button Is
 
Join Date: Sep 2005
Model: 7520
Posts: 31
Default Display GMT Time

Please Login to Remove!

Hi,
I'm trying to make my application display the time as GMT.

The handheld still needs to be set to PST.
So changing the Date/Time Time Zone to GMT is not an option.

I've tried doing this:

TimeZone _timeZone = TimeZone.getTimeZone("GMT");
Calendar _calendar = Calendar.getInstance(_timeZone);
Date _date = _calendar.getTime();
System.out.println(_date.toString());

But my time is still PST and it shows my time zone ID as "America/Los_Angeles"
Offline  
Old 05-31-2006, 12:36 PM   #2
phil_doyle
Knows Where the Search Button Is
 
Join Date: Sep 2005
Model: 7520
Posts: 31
Default

Bump
Offline  
Old 05-31-2006, 02:54 PM   #3
jonberry
Thumbs Must Hurt
 
Join Date: Apr 2005
Model: 950
Carrier: T-Mobile
Posts: 185
Default

Have you tried calling setTimeZone on the calendar instance?
Offline  
Old 05-31-2006, 04:33 PM   #4
phil_doyle
Knows Where the Search Button Is
 
Join Date: Sep 2005
Model: 7520
Posts: 31
Default

Still no luck.
This is how I used the Calendar.setTimeZone()

TimeZone _timeZone = TimeZone.getTimeZone("GMT");
Calendar _calendar = Calendar.getInstance();
_calendar.setTimeZone(_timeZone);
Date _date = _calendar.getTime();
System.out.println(_date.toString());

Anyone have any insight on this?
I'm trying to have my application display GMT, regardless of what Time Zone is set in Date/Time
Offline  
Old 05-31-2006, 04:43 PM   #5
phil_doyle
Knows Where the Search Button Is
 
Join Date: Sep 2005
Model: 7520
Posts: 31
Default

Figured it out

Last edited by phil_doyle; 06-01-2006 at 12:34 PM..
Offline  
Old 06-02-2006, 09:50 PM   #6
jonberry
Thumbs Must Hurt
 
Join Date: Apr 2005
Model: 950
Carrier: T-Mobile
Posts: 185
Default

Quote:
Originally Posted by phil_doyle
Figured it out
And?
Offline  
Old 06-07-2006, 08:12 PM   #7
phil_doyle
Knows Where the Search Button Is
 
Join Date: Sep 2005
Model: 7520
Posts: 31
Default

This is what I did:

// get the local time
Date _date = new Date();
long currentTime = _date.getTime();

// now we get the local time zone and date info
// the date info is passed into TimeZone.getOffset
// which gives us the GMT Offset, but also factor in
// Daylight Saving Time

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));

// now that we have our time
// and the GMT offset with DST considered
// we can display it (in long notation)
System.out.println("GMT Time as Long: " + currentTime - gmtOffset);
Offline  
Closed Thread



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

Forum Jump


Armco Policies Dec 1965 Steel Plant Vintage 26 pgs booklet Butler, Pa 29th print picture

Armco Policies Dec 1965 Steel Plant Vintage 26 pgs booklet Butler, Pa 29th print

$14.99



Original New DEC Digital DCJ11-AE 57-19400-09 Vintage CPU x 1pc picture

Original New DEC Digital DCJ11-AE 57-19400-09 Vintage CPU x 1pc

$100.00



DEC / AMI 304E 21-15542-01 vintage ceramic IC - KTF11 Chip *NEW* 40278101  picture

DEC / AMI 304E 21-15542-01 vintage ceramic IC - KTF11 Chip *NEW* 40278101

$50.00



Vintage Journal Beautiful Garden Flower Embossed Leather-Antique Handmade Dec... picture

Vintage Journal Beautiful Garden Flower Embossed Leather-Antique Handmade Dec...

$27.91



Dec/Adac Corp. D4-10390 Rev 6 Model 1664ATTL Output Pulse Board 1983 (B16) picture

Dec/Adac Corp. D4-10390 Rev 6 Model 1664ATTL Output Pulse Board 1983 (B16)

$189.99



VINTAGE Bruker Board DEC W4P3042 for SpectroSpin 250 picture

VINTAGE Bruker Board DEC W4P3042 for SpectroSpin 250

$50.00







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