سؤال

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top