.NET: Why is TryParseExact failing on Hmm and Hmmss?

后端 未结 6 761
闹比i
闹比i 2020-12-03 22:07

I\'m trying out the DateTime.TryParseExact method, and I have come over a case that I just don\'t get. I have some formats and some subjects to parse that each

6条回答
  •  抹茶落季
    2020-12-03 22:09

    If you do not use date or time separators in a custom format pattern, use the invariant culture for the provider parameter and the widest form of each custom format specifier. For example, if you want to specify hours in the pattern, specify the wider form, "HH", instead of the narrower form, "H"

    cite: http://msdn.microsoft.com/en-us/library/ms131044.aspx

    As others have pointed out H is ambiguous because it implies a 10 hour day, where as HH is 12

提交回复
热议问题