Prevent timezone conversion on deserialization of DateTime value

前端 未结 4 448
离开以前
离开以前 2020-12-01 10:40

I have a class that I serialize/deserialize using XmlSerializer. This class contains a DateTime field.

When serialized, the DateTime

4条回答
  •  时光取名叫无心
    2020-12-01 10:58

    What I did, it was to use DateTime.SpecifyKind method, as following:

    DateTime dateTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Unspecified);
    

    And this resolve my problem, I hope this help you.

提交回复
热议问题