DateTime vs DateTimeOffset

前端 未结 10 1833
刺人心
刺人心 2020-11-22 00:23

Currently, we have a standard way of dealing with .NET DateTime\'s in a TimeZone aware way: Whenever we produce a DateTime we do it in UTC (e.g. us

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 00:48

    The only negative side of DateTimeOffset I see is that Microsoft "forgot" (by design) to support it in their XmlSerializer class. But it has since been added to the XmlConvert utility class.

    XmlConvert.ToDateTimeOffset

    XmlConvert.ToString

    I say go ahead and use DateTimeOffset and TimeZoneInfo because of all the benefits, just beware when creating entities which will or may be serialized to or from XML (all business objects then).

提交回复
热议问题