How can a string timestamp with hours 0 to 24 be parsed
Posted
by
user897052
on Stack Overflow
See other posts from Stack Overflow
or by user897052
Published on 2012-09-11T21:23:26Z
Indexed on
2012/09/11
21:38 UTC
Read the original article
Hit count: 209
I am trying to parse a string timestamp of format "yyyyMMddHHmmss"
with DateTime.ParseExact()
. The catch is I must allow for an hour value of "24" (i.e. hours can be from 0 to 24; Note: I can't control the input values.) and, of course, that results in an exception.
Are there any settings/properties I can set instead of manually parsing/using regex's? If not, any efficient parsing ideas?
ex.
DateTime.ParseExact("20120911240000", "yyyyMMddHHmmss",
System.Globalization.CultureInfo.InvariantCulture);
hour 24 means hour 0 of next day (so day + 1, hour = 0)
© Stack Overflow or respective owner