我需要将 UTCDateTime字符串转换为ZonedDateTime.
UTCDateTime字符串只能是一种模式,因为 SharePoint类型列(M/dd/yyyy h:mm:ss tt)中仅支持此格式。DateTime
假设(5/28/2013 1:00:00 PM)作为我的 UTC 时间,我怎样才能将其转换为ZonedDateTime?我目前正在使用下面的代码来获取ZonedDateTime.
var dateTimeZone = DateTimeZoneProviders.Tzdb[zoneID];
var inst = Instant.FromUtc(year, month, day, hour, minute);
ZonedDateTime dz = new ZonedDateTime(inst, dateTimeZone);
上面的代码需要year, month, day, hour, 和minuteasint值。有没有更简单的方法可以ZonedDateTime直接从 UTC 字符串中获取?