using System;
namespace ConsoleApplication_C_Sharp
{
public class TimeZoneClass
{
private DateTimeOffset dt;
private TimeZoneInfo tz;
public TimeZoneClass(DateTimeOffset dateTime, TimeZoneInfo timeZone)
{
dt = dateTime;
tz = timeZone;
}
public DateTimeOffset DateTime
{
get { return dt; }
}
public TimeZoneInfo TimeZone
{
get { return tz; }
}
}
class Program
{
static void Main(string[] args)
{
TimeZoneClass[] timeZoneObjects = { new TimeZoneClass(DateTime.Now, TimeZoneInfo.Local),
new TimeZoneClass(DateTime.Now, TimeZoneInfo.Utc) };
foreach (var timeZoneO in timeZoneObjects)
Console.WriteLine("{0}: {1:G}",
timeZoneO.TimeZone == null ? "<null>" : timeZoneO.TimeZone.ToString(),
timeZoneO.DateTime);
}
}
}
/*
run:
(UTC+02:00) Jerusalem: 12-4-16 7:52:18 AM
UTC: 12-4-16 7:52:18 AM
*/