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