Observed similar behavior in one of our WCF services - our specific case is DateTimeOffset values deserialized from incoming requests using Newtonsoft.Json are getting converted to strings with DateTimeOffset.ToString() and we are ending up with string representations that look like this
MM/dd/yyyy 12:00:00 AM -04:00 -04:00
Our first assumption was obviously that this was a bug in our code - its always your code, right? However, we traced execution pretty exhaustively on our end and couldn't find any possible way we would be causing this issue ourselves - as hard as it is to believe, it seems like the result of DateTimeOffset.ToString
really is just returning that string format on the server.
The specific string conversion that's causing the error on our end is happening in an internal framework, so we're just swapping out the way we convert so that we're now using an explicit string format. No confirmation if that works or not yet. Our replacement implementation looks like this -
offset.ToString("MM/dd/yyyy HH:mm:ss tt zzzz");
Our short term solution was to restart the IIS application pool - the issue immediately stopped exhibiting after this both times we encountered it.