How to convert a UTC DateTimeOffset to a DateTime that uses the systems timezone
quartz.net提供了获取下一次触发事件的方法:http://quartz net.sourceforge.net/apidoc/1.0/html/html/cc03bb79-c0c4-6d84-3d05-a17f59727c98.htm
docs声称这个
我做了这个
您只需使用
1 | trigger.GetNextFireTimeUtc().Value.LocalDateTime |
从文档中:
If necessary, the LocalDateTime property converts the current DateTimeOffset object's date and time to the local system's date and time. The conversion is a two-step operation:
- The property converts the current DateTimeOffset object's time to Coordinated Universal Time (UTC).
- The property then converts UTC to local time.
不过,您应该真正了解
此代码用于将UTC转换为本地
1 | var local = utc.ToLocalTime(); |