C# TimeZoneInfo ConvertTimeBySystemTimeZoneId(DateTimeOffset, String)
Description
TimeZoneInfo ConvertTimeBySystemTimeZoneId(DateTimeOffset,
String)
converts a time to the time in another time zone based on the
time zone's identifier.
Syntax
TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset, String)
has the following syntax.
public static DateTimeOffset ConvertTimeBySystemTimeZoneId(
DateTimeOffset dateTimeOffset,
string destinationTimeZoneId
)
Parameters
TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset, String)
has the following parameters.
dateTimeOffset
- The date and time to convert.destinationTimeZoneId
- The identifier of the destination time zone.
Returns
TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset, String)
method returns The date and time in the destination time zone.
Example
using System;/* w w w .ja va2s . c o m*/
public class MainClass
{
public static void Main(String[] argv)
{
DateTimeOffset hwTime = DateTimeOffset.Now;
TimeZoneInfo hwZone = TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time");
Console.WriteLine(TimeZoneInfo.ConvertTimeBySystemTimeZoneId(hwTime, "Hawaiian Standard Time"));
}
}
The code above generates the following result.