本文整理汇总了C#中System.TimeZoneInfo.FindSystemTimeZoneById方法的典型用法代码示例。如果您正苦于以下问题:C# TimeZoneInfo.FindSystemTimeZoneById方法的具体用法?C# TimeZoneInfo.FindSystemTimeZoneById怎么用?C# TimeZoneInfo.FindSystemTimeZoneById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了TimeZoneInfo.FindSystemTimeZoneById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
public class Example
{
public static void Main()
{
// Get time in local time zone
DateTime thisTime = DateTime.Now;
Console.WriteLine("Time in {0} zone: {1}", TimeZoneInfo.Local.IsDaylightSavingTime(thisTime) ?
TimeZoneInfo.Local.DaylightName : TimeZoneInfo.Local.StandardName, thisTime);
Console.WriteLine(" UTC Time: {0}", TimeZoneInfo.ConvertTimeToUtc(thisTime, TimeZoneInfo.Local));
// Get Tokyo Standard Time zone
TimeZoneInfo tst = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
DateTime tstTime = TimeZoneInfo.ConvertTime(thisTime, TimeZoneInfo.Local, tst);
Console.WriteLine("Time in {0} zone: {1}", tst.IsDaylightSavingTime(tstTime) ?
tst.DaylightName : tst.StandardName, tstTime);
Console.WriteLine(" UTC Time: {0}", TimeZoneInfo.ConvertTimeToUtc(tstTime, tst));
}
}
// The example displays output like the following when run on a system in the
// U.S. Pacific Standard Time zone:
// Time in Pacific Standard Time zone: 12/6/2013 10:57:51 AM
// UTC Time: 12/6/2013 6:57:51 PM
// Time in Tokyo Standard Time zone: 12/7/2013 3:57:51 AM
// UTC Time: 12/6/2013 6:57:51 PM