NetCoreForce icon indicating copy to clipboard operation
NetCoreForce copied to clipboard

Dates are being deserialized with kind Local (with potential fix)

Open crochik opened this issue 11 months ago • 3 comments

Noticed yesterday that dates were coming back with kind Local.

It is my understanding dates from salesforce are all provided as UTC but because of their format (e.g. 2017-05-30T21:10:25.000+0000) the JsonConvert.DeserializeObject by default will attempt some kind of conversion to Local.

It seems like a simple fix (that worked for me):

In JsonClient.cs wherever the JsonConvert.DeserializeObject<T>(...) is being used to deserialize the response, replace with:

JsonConvert.DeserializeObject<T>(..., new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Utc })

crochik avatar Feb 11 '25 14:02 crochik