以下是我的DTO。爲什麼在DateTime屬性中添加時區
public class CustomerTO
{
public int Id { get; set;}
public DateTime? RDate {get;set;}
public DateTime? LDate {get; set;}
}
當我在數據庫檢查是相應的列RDATE & LDate值如下: -
RDate = 2017-04-03 21:09:24.273
LDate = 2017-04-03 21:09:24.577
我的行動。
public string Get()
{
var customers = dal.GetRecords();
//if I hover the customers object & see the RDate or LDate value it is as desired.
var strJson= JsonConvert.SerializeObject(customers);
//but here the value of RDate/LDate has Time zone appended.
}
strJson包含RDate & LDate值如下。
RDate = 2017-04-03T21:09:24.5768697+05:30
LDate = 2017-04-03T21:09:24.5618688+05:30 // why +5:30 timezone is getting appended.
如何解決?
任何幫助/建議高度讚賞。
它的存在,所以如果JSON是另一個時區反序列化,原來的日期/時間將被保留。 – stuartd
@stuartd,對不起,我沒有找到你 –