Java TimeZone getDisplayName() 方法

2024年11月7日 | 阅读 2 分钟

TimeZone 类的 getDisplayName(boolean daylight, int style) 方法返回指定样式的名称。样式可以是 LONG 或 SHORT。如果 daylight 为 true,它返回夏令时的名称。否则,它返回标准时间的名称。

语法

参数

Daylight - 如果 daylight 为 true,则返回夏令时的名称,否则返回标准时间的名称。

style - 它可以是 LONG(1) 或 SHORT(0)

返回值

它以人类可读的形式返回时区的名称。

示例 1

输出

Display name is :IDT

示例 2

输出

Display name is :India Daylight Time

Java TimeZone getDisplayName() 方法

TimeZone 类的 getDisplayName() 方法返回时间的标准名称。

语法

返回值

它以人类可读的形式返回时区的名称。

示例 3

输出

Default Name:India Standard Time