C# TimeZoneInfo FindSystemTimeZoneById
Description
TimeZoneInfo FindSystemTimeZoneById
retrieves a TimeZoneInfo
object from the registry based on its identifier.
Syntax
TimeZoneInfo.FindSystemTimeZoneById
has the following syntax.
public static TimeZoneInfo FindSystemTimeZoneById(
string id
)
Parameters
TimeZoneInfo.FindSystemTimeZoneById
has the following parameters.
id
- The time zone identifier, which corresponds to the Id property.
Returns
TimeZoneInfo.FindSystemTimeZoneById
method returns An object whose identifier is the value of the id parameter.
Example
The following example uses the FindSystemTimeZoneById method to retrieve the Tokyo Standard Time zone.
/*from w ww .jav a 2 s.co m*/
using System;
public class Example
{
public static void Main()
{
DateTime thisTime = DateTime.Now;
// Get Tokyo Standard Time zone
TimeZoneInfo tst = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
DateTime tstTime = TimeZoneInfo.ConvertTime(thisTime, TimeZoneInfo.Local, tst);
}
}
The code above generates the following result.