I'm trying to get a handle on using the Noda Time framework by Jon Skeet (and others).
How do I store the DateTimeZone and retrieve it from the database. I thought the Id property value might be the one to set to the database, but how do I create a DateTimeZone from the Id since DateTimeZone is an abstract class?
Storing the ID is fine, and you'd get it back using the relevant IDateTimeZoneProvider
and its indexer, normally retrieved via DateTimeZoneProviders
. For example:
var london = DateTimeZoneProviders.Tzdb["Europe/London"];
You do need to know which provider you used, of course - IDs are only scoped to the provider, effectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With