C# TimeZoneInfo ClearCachedData
Description
TimeZoneInfo ClearCachedData
clears cached time zone data.
Syntax
TimeZoneInfo.ClearCachedData
has the following syntax.
public static void ClearCachedData()
Returns
TimeZoneInfo.ClearCachedData
method returns
Example
//from w w w. j a va 2 s . c o m
using System;
public class MainClass{
public static void Main(String[] argv){
TimeZoneInfo cst = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
TimeZoneInfo local = TimeZoneInfo.Local;
Console.WriteLine(TimeZoneInfo.ConvertTime(DateTime.Now, local, cst));
TimeZoneInfo.ClearCachedData();
try
{
Console.WriteLine(TimeZoneInfo.ConvertTime(DateTime.Now, local, cst));
}
catch (ArgumentException e)
{
Console.WriteLine(e.GetType().Name + "\n " + e.Message);
}
}
}
The code above generates the following result.