是否有解析超过 24 小时的日期的规范解决方案?
例如,对于这样的
'2022.05.22 24:00'
'2022.05.22 24:10'
我发现的错误
Exception has occurred: CLR/System.FormatException
An unhandled exception of type 'System.FormatException' occurred in System.Private.CoreLib.dll: 'The DateTime represented by the string '2022.05.22 24:00' is not supported in calendar 'System.Globalization.GregorianCalendar'.'
给我这个的代码行
...
// values[0]="2022.05.22" и values[1]="24:00"
dateteime = DateTime.Parse((values[0] + ' ' +values[1]), CultureInfo.InvariantCulture),
我明白我可以做到Replace
这一点
...
// values[0]="2022.05.22" и values[1]="24:00"
dateteime = DateTime.Parse((values[0] + ' ' +values[1].Replace("24:", "00:")), CultureInfo.InvariantCulture),
enSO 充斥着这类问题,但它们要么已经存在 10 年,要么没有价值,因为它们只解决了部分日期问题。或者,也许我在寻找错误的地方。
像这样的东西。