Skip to main content

Posts

Showing posts with the label DateTime

Understanding DateTime.ParseExact

When searching information about DateTime.ParseExact all documentations and blogs mention that the 'dateString' and the 'formatString' must be identical with the same date & time separators and format. Although true, it's not the a precise description of what is going on under the hoods. Some times when needed this rule can be bypassed. I will explain later how. For now lets see the steel thread: string dateString = "2012-01-01 13:30" string formatString = "yyyy-MM-dd HH:mm"; DateTime.ParseExact(dateString,formatString ,currentCultureFormatter) string dateString = "2012 01~01 13|30" string formatString = "yyyy MM~dd HH|mm"; DateTime.ParseExact(dateString,formatString ,currentCultureFormatter) string dateString = "2012-01|01 13~30" string formatString = "yyyy-MM|dd HH~mm"; DateTime.ParseExact(dateString,formatString ,currentCultureFormatter) ...