简体   繁体   中英

.net core 3.1 to .net Core 5 upgrade gives wrong conversion for datetime values? Any document for this breaking changes and solution

Recently upgrade one application from .NET Core 3.1 to .NET 5. For some reason the DateTimeKind was Local in 3.1 and now it is UTC in .NET 5.

I created a simple project showing this problem,

https://github.com/ShehulCS/Dotnet5DateTimeIssue

Question,

  1. Can anyone please confirm from Microsoft docs, if this was the change they introduce between 2 versions, is it a bug or new design? Online search doesn't lead me to anything useful on this.

The issue you're describing is related to a bug fix.

In short, the Z at the end of an ISO 8601 timestamp explicitly means UTC. The bug was that when such a value is obtained through model binding, it was previously being interpreted as DateTimeKind.Local instead of DateTimeKind.Utc . That bug has been corrected in 5.0.

The new behavior is correct. If you were relying on the old behavior, you probably have other .NET code that needs to be corrected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM