6

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?

Chuck Savage
  • 11,775
  • 6
  • 49
  • 69

1 Answers1

6

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.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194