Working with DateTimeOffset

自作多情 提交于 2019-12-11 09:36:40

问题


I have some problems understanding the DateTimeOffset...

I am trying to create a simple-trigger for a Quartz-Job. There exists a triggerbuilder with which one can create such a trigger like this:

var triggerbuilder =
                TriggerBuilder.Create()
                .WithIdentity(triggerName, ConstantDefinitions.InternalDefinitions.AdhocJobGroup)
                .StartAt(new DateTimeOffset(scheduledTime));

The scheduledTime is a DateTime. Let's say it is new DateTime(2014, 10, 15, 14, 0, 0);

I live in a city which lies in the Central European Time Zone (UTC+01:00).

When I print

var dto = new DateTimeOffset(new DateTime(2014, 10, 15, 14, 0, 0));
Console.WriteLine(dto);

I get the following result:

15.10.2014 14:00:00 +02:00

What does the +02:00 exactly mean? And why is it +2:00 and not +01:00? Does that mean, that my trigger will be started at 16:00 instead of 14:00?

Thanks in advance


回答1:


15.10.2014 14:00:00 +02:00 is a datetimeoffset (datetime + timezone) representing 2pm local time in a timezone of +2 UTC

this is equivalent to 15.10.2014 12:00:00 in UTC

With regard to why is it +02:00 rather than +01:00, is daylight savings active?

Converting Between DateTime and DateTimeOffset



来源:https://stackoverflow.com/questions/26382559/working-with-datetimeoffset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!