我在数据库中有一个事件日志,事件的日期时间存储为 UTC 时间。在我使用 NodaTime 的应用程序中,我将值作为 a 获取DateTime
,然后将其转换为Instant
:
var instant = NodaTime.Instant.FromDateTimeUtc(DateTime.SpecifyKind(eventDateTime, DateTimeKind.Utc));
现在我想获得ZonedDateTime
与instant
使用系统时区相对应的信息。我知道我可以用它instant.InZone(systemTimeZone)
来获得ZonedDateTime
我需要的东西。但是,我不知道如何systemTimeZone
用正确的值填充变量。如何获取DateTimeZone
系统时区对应的对象?