Returns the display name of the zone based on the provided style and locale.
package com.logicbig.example.zoneid;
import java.time.ZoneId;
import java.time.format.TextStyle;
import java.util.Locale;
public class GetDisplayNameExample {
public static void main(String... args) {
ZoneId z = ZoneId.of("America/New_York");
System.out.println(z);
for (TextStyle textStyle : TextStyle.values()) {
String s = z.getDisplayName(textStyle, Locale.getDefault());
System.out.printf("%18s > %s%n", textStyle, s);
}
}
}
Output
America/New_York
FULL > Eastern Time
FULL_STANDALONE > Eastern Time
SHORT > ET
SHORT_STANDALONE > ET
NARROW > America/New_York
NARROW_STANDALONE > ET