What's the equivalent in C# of TimeZone.getDefault().getID() in Java?

c#, java, jodatime, nodatime, timezone

Solution

.Net does not natievely support the TZDB, because Microsoft has it's own time zone database. See the TimeZone tag wiki for details.

If you want to work with TZDB zones, use the NodaTime library. The exact translation of what you asked is:

using NodaTime;

...

var timeZoneId = DateTimeZoneProviders.Tzdb.GetSystemDefault().Id;
Console.WriteLine(timeZoneId);

Problem

For one lives in Republic of Molossia, the following code in Java: ``` String TimeZoneId=TimeZone.getDefault().getID(); System.out.println(TimeZoneId); ``` will print America/Regina I tried `TimeZoneInfo.GetSystemTimeZones()` but the return value doesn't seem a tzdb id. Is there an equivalent method in C#?

Original source

Related problems