TimeZoneInfo.DisplayName 属性
定义
获取表示时区的一般显示名称。Gets the general display name that represents the time zone.
public:
property System::String ^ DisplayName { System::String ^ get(); };
public string DisplayName { get; }
member this.DisplayName : string
Public ReadOnly Property DisplayName As String
属性值
时区的一般显示名称。The time zone's general display name.
示例
下面的示例检索一个 TimeZoneInfo 对象,该对象表示本地时区并输出其显示名称、标准时间名称和夏时制名称。The following example retrieves a TimeZoneInfo object that represents the local time zone and outputs its display name, standard time name, and daylight saving time name. 系统将显示美国太平洋标准时区的输出。The output is displayed for a system in the U.S. Pacific Standard Time zone.
using System;
public class Example
{
public static void Main()
{
TimeZoneInfo localZone = TimeZoneInfo.Local;
Console.WriteLine("Local Time Zone ID: {0}", localZone.Id);
Console.WriteLine(" Display Name is: {0}.", localZone.DisplayName);
Console.WriteLine(" Standard name is: {0}.", localZone.StandardName);
Console.WriteLine(" Daylight saving name is: {0}.", localZone.DaylightName);
}
}
// The example displays output like the following:
// Local Time Zone ID: Pacific Standard Time
// Display Name is: (UTC-08:00) Pacific Time (US & Canada).
// Standard name is: Pacific Standard Time.
// Daylight saving name is: Pacific Daylight Time.
Module Example
Public Sub Main()
Dim localZone As TimeZoneInfo = TimeZoneInfo.Local
Console.WriteLine("Local Time Zone ID: {0}", localZone.Id)
Console.WriteLine(" Display Name is: {0}.", localZone.DisplayName)
Console.WriteLine(" Standard name is: {0}.", localZone.StandardName)
Console.WriteLine(" Daylight saving name is: {0}.", localZone.DaylightName)
End Sub
End Module
' The example displays output like the following:
' Local Time Zone ID: Pacific Standard Time
' Display Name is: (UTC-08:00) Pacific Time (US & Canada).
' Standard name is: Pacific Standard Time.
' Daylight saving name is: Pacific Daylight Time.
注解
显示名称根据 Windows 操作系统中安装的区域性进行了本地化。The display name is localized based on the culture installed with the Windows operating system.
Windows 系统时区的时区显示名称遵循相当标准的格式。Time zone display names for Windows system time zones follow a fairly standard format. 显示名称的第一部分是时区相对于协调世界时的基本偏移量,它由 "格林尼治标准时间) " 的缩写项 " (" 括在括号中。The first portion of the display name is the time zone's base offset from Coordinated Universal Time, which is indicated by the acronym GMT (for Greenwich Mean Time), enclosed in parentheses. 对于协调世界时,不含偏移的 GMT 首字母缩略词括在括号中。For Coordinated Universal Time, the GMT acronym with no offset is enclosed in parentheses. 后跟一个字符串,该字符串标识时区或时区中的一个或多个城市、区域或国家/地区。This is followed by a string that identifies the time zone or one or more of the cities, regions, or countries in the time zone. 例如:For example:
(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London
(GMT+02:00) Athens, Beirut, Istanbul, Minsk
(GMT-02:00) Mid-Atlantic
(GMT-07:00) Mountain Time (US & Canada)