Reputation: 1585
How to get the zone info from timezone object?
I have a TimeZone
java object and I need to display the info as below
ex: IST - India Standard Time - (GMT+5.30)
I can get the IST - id and display name (Indian Standard Time) and offset as 5:30
.
How to get the zone - GMT ???
Thanks.
Upvotes: 0
Views: 1135
Reputation: 2404
For displaying in zone-Id - zone-Name - (GMT standard offset)
format
set to required time zone
get required data from above object
TimeZone tz = TimeZone.getTimeZone("Asia/Calcutta");
tz.getID() // for zone-id
tz.getDisplayName() // for zone-Name
tz.getOffset(TimeZone.getDefault().getID()) // for GMT standard offset
Upvotes: 2
Reputation: 4517
Simply use TimeZone.getTimeZone("GMT")
. If you want to check if ID exists try using TimeZone.getAvailableIDs()
.
Upvotes: 0