【发布时间】:2013-12-28 05:05:45
【问题描述】:
我在数据库中有一个事件日志,事件的日期时间存储为 UTC 时间。在我使用 NodaTime 的应用程序中,我将值作为DateTime 获取,然后将其转换为Instant:
var instant = NodaTime.Instant.FromDateTimeUtc(DateTime.SpecifyKind(eventDateTime, DateTimeKind.Utc));
现在我想使用系统的时区获取与instant 对应的ZonedDateTime。我知道我可以使用instant.InZone(systemTimeZone) 来获得我需要的ZonedDateTime。但是,我不知道如何用正确的值填充 systemTimeZone 变量。如何获取系统时区对应的DateTimeZone对象?
【问题讨论】: