Newtonsoft.Json DateTime bug?

Apr 1, 2014 at 8:22 PM
Hi all,


In the code below:
JsonSerializerSettings settings = new JsonSerializerSettings();
settings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;

DateTime date1 = DateTime.Now;
string jsonString = JsonConvert.SerializeObject(date1, settings);
DateTime date2 = JsonConvert.DeserializeObject<DateTime>(jsonString, settings);

Console.WriteLine(date1);
Console.WriteLine(date2);
The date1 and date2 are printed different. If I comment the Utc setting, they became equal.

Is it a bug?

Regards,
Alexandre
Apr 1, 2014 at 8:29 PM
Hi all,

I just find out. I should convert both to localtime.

Cheers,
Alexandre
Marked as answer by xandemaki on 4/1/2014 at 1:30 PM