Discussion:
Inconsistent results from DateTimeConverter.ConvertToInvariantString
(too old to reply)
Marcel Mueller
2016-02-03 15:18:05 UTC
Permalink
System.ComponentModel.TypeDescriptor.GetConverter(typeof(DateTime)).ConvertToInvariantString(new
DateTime(2016,2,2))

"2016-02-02"

System.ComponentModel.TypeDescriptor.GetConverter(typeof(DateTime)).ConvertToInvariantString(DateTime.MaxValue)

"12/31/9999 23:59:59"

What the hell is going on here?


Marcel
Arne Vajhøj
2016-02-04 03:25:54 UTC
Permalink
Post by Marcel Mueller
System.ComponentModel.TypeDescriptor.GetConverter(typeof(DateTime)).ConvertToInvariantString(new
DateTime(2016,2,2))
"2016-02-02"
System.ComponentModel.TypeDescriptor.GetConverter(typeof(DateTime)).ConvertToInvariantString(DateTime.MaxValue)
"12/31/9999 23:59:59"
What the hell is going on here?
Good question.

One observation though: it looks like the difference is triggered by
whether the time part is all zero or not.

Try with:

new DateTime(9999,12,31)
new DateTime(2016,2,2,23,59,59)

Arne

Loading...