Java/android – TimeZone is a 3-letter abbreviation for the consistent way … here is a solution to the problem.
Java/android – TimeZone is a 3-letter abbreviation for the consistent way
How to get a three-letter abbreviation for a time zone in Java
For example: TimeZone.getTimeZone("Pacific/Auckland").getDisplayName
to me:
GMT+12
But I want NZST
or NZDT
.
Is this possible?
Solution
Use Joda time
DateTimeZone dz = DateTimeZone.forID("Pacific/Auckland");
String timezone = dz.getNameKey(DateTimeUtils.currentTimeMillis()); NZST
Add – in your build.gradle
implementation 'joda-time:joda-time:2.10'