Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
DateTime.Parse/TryParse fails if the date and time uses the same separator #4409
The following code (in .NET 4.6) throws a FormatException:
Windows 10 for some reason changed the time separator for some locales (norwegian, finnish and serbian) which now breaks with Parse and TryParse.
edit: missed the format on the parse.
This is known issue and not a new one. the parser is just thinking it is parsing a time (and not a date) and then decide it is not valid time. in general the Parse/TryParse is not guaranteeing the parse all possible strings and we always recommend to use ParseExact/TryParseExact to guarantee successful parsing.
Regarding the same issue in .NET Framework, see my blog post at http://www.heikniemi.net/hardcoded/2015/08/windows-10-breaks-net-date-parsing-in-certain-locales/. And now that the state machine has been fixed there, I hope the fix will flow down here as well :-)