GJain :
How can I get three letter abbreviations in Java for a TimeZone
For eg: TimeZone.getTimeZone("Pacific/Auckland").getDisplayName
gives me:
GMT+12
but I want NZST
or NZDT
.
Is it possible?
Amit K. Saha :
Use Joda-Time
DateTimeZone dz = DateTimeZone.forID("Pacific/Auckland");
String timezone = dz.getNameKey(DateTimeUtils.currentTimeMillis()); // NZST
In your build.gradle
add -
implementation 'joda-time:joda-time:2.10'