java.time.ZoneId.getDisplayName()方法获取区域的文本表示,例如:"British Time"或"+02:00"。
声明
以下是java.time.ZoneId.getDisplayName()方法的声明。
public String getDisplayName(TextStyle style, Locale locale)
参数
style- 所需文本的长度,而不是null。locale- 要使用的语言环境,而不是null。
返回值
区域的文本值,不为null。
示例
以下示例显示了java.time.ZoneId.getDisplayName()方法的用法。
package com.zaixian;
import java.time.ZoneId;
import java.time.format.TextStyle;
import java.util.Locale;
public class ZoneIdDemo {
public static void main(String[] args) {
ZoneId zoneId = ZoneId.of("Z");
System.out.println(zoneId.getDisplayName(TextStyle.SHORT,Locale.ENGLISH));
}
}
编译并运行上面的程序,这将产生以下结果 -
Z
上一篇:
java.time.ZoneId类
下一篇:
java.time.ZoneOffset类
