My time zone is UTC+03:00. It is stored inside a DateTimeZone object. How do I convert this to its real name, that is, East Africa Time/EAT
With joda, one can get Time-zone abbreviation or name as below
DateTimeZone dz = DateTimeZone.forID("America/New_York");
String tzid = dz.getShortName(DateTimeUtils.currentTimeMillis());
//tzid will be 'EST'
String longerTimeZoneName = dz.getName(DateTimeUtils.currentTimeMillis());
//longerTimeZoneName will be 'Eastern Standard Time'
Use method TimeZone#getDisplayName()
DateTimeZone tz = //...
tz.toTimeZone().getDisplayName();
I have not been able to find anything in JodaTime to give the nice readable name. In my experience, the DateTimeZone.getName() returns the id instead of a more useful name. So I can only get "America/New_York", not "Eastern Standard Time".
And the suggest of TimeZone.getDisplayName seems to assume you are using TimeZone from Java, not Joda. I see no getDisplayName() for JodaTime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With