I have to deserialize a JSON string in C#. And in my serealize JSON string there is a datetime field. Below is the JSON string format -
{"Date" : "2016-09-20T18:29:00.0000000"}
But when I am desealizing the above string like below -
Newtonsoft.Json.JsonConvert.DeserializeObject<T>(entity, new IsoDateTimeConverter {
DateTimeFormat = "yyyy-MM-dd'T'HH:mm:ss.fffffff"
});
I am getting the below string-
{"Date" : "2016-09-20T18:29:00"}
Means I am not getting the milliseconds value while it's 000.
Can anyone help me out on this.
Updating my question :
Actually I am deserializing my object/entity by Newtonsoft and which there is a datetime field which I want to format.
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(entity, new IsoDateTimeConverter
{
DateTimeFormat = "yyyy-MM-dd'T'HH:mm:ss.fffffff"
});
But as a result I am not getting the datetime format that I mentioned. It's truncating the datetime string from milliseconds. Below is my datetime string -
2016-09-20T18:29:00.000
And I am getting string like below after deserialzation -
2016-09-20T18:29:00