Reputation: 5273
I want the country name(time zone id) based on time zone like
america/new_york
My current code is
String time_zone = TimeZone.getDefault().getDisplayName(false, TimeZone.SHORT);
This returns GMT-05:00
Upvotes: 0
Views: 1100
Reputation: 140318
The country is not part of the time zone data.
For instance, it's not reliably encoded in the ID, as in Africa/Abidjan
or America/Cancun
.
The only way you can do this is with an explicit lookup table mapping time zone id to country.
Upvotes: 3
Reputation: 443
you can get country name using this
TimeZone.getDefault().getID()
Upvotes: 3