here i am giving my code and what happen.
when i am passing timezone id to .net time zone that works the code as below
var zoneId = "India Standard Time";
var zone = TimeZoneInfo.FindSystemTimeZoneById(zoneId);
var now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, zone);
string xx1 = now.ToLongTimeString();
when i am passing the same time zone id India Standard Time to noda time library then i am getting error "Time zone India Standard Time is unknown to source TZDB: 2014e (mapping: 9723)"
my code as follows for noda time
var zoneId = "India Standard Time";
DateTimeZone _zone = DateTimeZoneProviders.Tzdb[zoneId];
ZonedDateTime _now = SystemClock.Instance.Now.InZone(_zone);
string xx= now.ToLongTimeString();
just tell me how to pass timezone to noda library for India Standard Time or GMT Standard Time
thanks
If you want to pass a BCL time zone to Noda Time, you just need to use the BCL provider:
DateTimeZone _zone = DateTimeZoneProviders.Bcl[zoneId];
This will find the relevant TimeZoneInfo
, extract its adjustment rules, and convert that into a Noda Time representation. You can then use it just like any other DateTimeZone
.
Note that these time zone IDs are Windows-specific. If you can uses the IANA (TZDB) time zone IDs instead, that would generally make your data more portable to other systems.
See more on this question at Stackoverflow