If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
hims_3009
Posts: 227
Registered: ‎12-16-2009
My Device: 9530,8900,9000
My Carrier: Airtel,Docomo

Retrieve name of the TimeZone like "Indian Stanard Time"

Hi All,

I am trying to Retrieve the name of TimeZone like "Indian Stanard Time".

 

I am using below method to retrieve the TimeZone

String timeZone=TimeZoneUtilities.getDisplayName(TimeZone.getDefault(),TimeZoneUtilities.LONG);

which returns:- (GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi

 

&

 

String timeZone1=TimeZoneUtilities.getDisplayName(TimeZone.getDefault(),TimeZoneUtilities.SHORT);

which returns:- Kolkata (+5.5)

 

But I am not able to find the name like "Indian Stanard Time". Whcih is possible in Android using TimeZone class but in BB I am not able to retrieve that So is there any method/API  that gives me the name like

"Indian Stanard Time".

 

 

 

Lathiya Himanshu
Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Retrieve name of the TimeZone like "Indian Stanard Time"

The API allows you to retrieve the list of time zones you see under Options, Date/Time, Time Zone.  Indian Standard Time is not listed there (at least on the BlackBerry Smartphone I checked).  If you are seeing different behaviour please let us know what BlackBerry Smartphone model and BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Trusted Contributor
hims_3009
Posts: 227
Registered: ‎12-16-2009
My Device: 9530,8900,9000
My Carrier: Airtel,Docomo

Re: Retrieve name of the TimeZone like "Indian Stanard Time"

I am Testing on Curve 3G 9300.

Yes API list out TimeZones as we can see under options->Date/Time->TimeZone.

I just want to confirm that it is possible to list out the Name like "Indian Standard Time" same is possible in Android.

 

Lathiya Himanshu
Please use plain text.
New Contributor
nkuntala
Posts: 5
Registered: ‎10-03-2011
My Device: 9800
My Carrier: BSNL

Re: Retrieve name of the TimeZone like "Indian Stanard Time"

I tried using TimeZone and TimeZoneUtilities class as well but still not able to get the desired result. I need to display the short name of timezone for e.g. "IST" instead of "Indian Standard Time" or any other. However, I could only manage to get "Asia/Pacific" or "Kolkata (+5.5)" using the APIs. Can anyone say how to get only the short name of the selected timezone?

 

Below is my piece of code:

 

// this gives "Kolkata (+5.5)"

TimeZoneUtilities.getDisplayName(TimeZone.getDefault(), TimeZoneUtilities.SHORT) 

 

// this gives "Asia/Pacific"

(TimeZone.getDefault()).getID());

 

Can anyone suggest?

Please use plain text.
Trusted Contributor
hims_3009
Posts: 227
Registered: ‎12-16-2009
My Device: 9530,8900,9000
My Carrier: Airtel,Docomo

Re: Retrieve name of the TimeZone like "Indian Stanard Time"

We can not retrieve the name like "IST" because BB does not support the core JAVA API's.

I think that BlackBErry should support the Core JAVA API's as Supported by Android.

Though BB's Native code is in java but still its not supporting core java API's.

RIM think about it.

Make our Develooper's life Easy.

Lathiya Himanshu
Please use plain text.
New Contributor
nkuntala
Posts: 5
Registered: ‎10-03-2011
My Device: 9800
My Carrier: BSNL

Re: Retrieve name of the TimeZone like "Indian Stanard Time"

The only way to do this is to get all  timezones that the device supports and put them into a hashtable. The make the hastable as a key-value pair of the "retrieved timezone+short form of the corresponding timezone". And when the app runs, check which timezone is selected and appropriately display the shortname of the selected timezone.

 

This may be a tedious task to do, but I could figure out only this way and it worked really well. Remember, there might be some timezones added in the latest  OS versions which may not be available on older devices.

 

Thanks,

Nanda K.

Please use plain text.