System.TimeZoneInfo.FindSystemTimeZoneById C# (CSharp) Method

FindSystemTimeZoneById() public static method

public static FindSystemTimeZoneById ( string id ) : TimeZoneInfo
id string
return TimeZoneInfo
		public static TimeZoneInfo FindSystemTimeZoneById (string id)
		{
			//FIXME: this method should check for cached values in systemTimeZones
			if (id == null)
				throw new ArgumentNullException ("id");
#if !MOBILE
			if (TimeZoneKey != null)
			{
				if (id == "Coordinated Universal Time")
					id = "UTC"; //windows xp exception for "StandardName" property
				RegistryKey key = TimeZoneKey.OpenSubKey (id, false);
				if (key == null)
					throw new TimeZoneNotFoundException ();
				return FromRegistryKey(id, key);
			}
#endif
			// Local requires special logic that already exists in the Local property (bug #326)
			if (id == "Local")
				return Local;

			return FindSystemTimeZoneByIdCore (id);
		}

Usage Example

Esempio n. 1
0
        public void TestCronTriggerTimeZone_TimeZoneShouldChangeWhenChanged()
        {
            string tzStr = "FLE Standard Time";

            if (TimeZone.Local.Id == tzStr)
            {
                tzStr = "GMT Standard Time";
            }
            TimeZone    tz      = TimeZone.FindSystemTimeZoneById(tzStr);
            CronTrigger trigger = new CronTrigger();

            trigger.Name                 = "Quartz-579";
            trigger.Group                = SchedulerConstants.DefaultGroup;
            trigger.TimeZone             = tz;
            trigger.CronExpressionString = "0 0 12 * * ?";
            Assert.AreEqual(tz, trigger.TimeZone, "TimeZone was changed");
        }
All Usage Examples Of System.TimeZoneInfo::FindSystemTimeZoneById