White space issue when parsing datetime Options

  • Thread starter Thread starter parez
  • Start date Start date
P

parez

Hi All,

i have two accepted formats.


expectedFormats = New String() {"%M/%d/yyyy", "%M/%d/yyyy hh:mm:ss
tt"}


dt = DateTime.ParseExact(txtInpDateString.Text, expectedFormats,
culture.DateTimeFormat,
Globalization.DateTimeStyles.AllowWhiteSpaces)


and i get 05/14/200711:22:33 AM as a valid date. (Note: there is no
space between year and time) and i am pretty sure zero lenght string
is not a white space.


Please help
 
Are you saying that you want the parsing to fail in that situation?
 
Sorry about that!!
Yes i am saying it should fail
Are you saying that you want the parsing to fail in that situation?

--
- Nicholas Paldino [.NET/C# MVP]



i have two accepted formats.
expectedFormats = New String() {"%M/%d/yyyy", "%M/%d/yyyy hh:mm:ss
tt"}
dt = DateTime.ParseExact(txtInpDateString.Text, expectedFormats,
culture.DateTimeFormat,
Globalization.DateTimeStyles.AllowWhiteSpaces)
and i get 05/14/200711:22:33 AM as a valid date. (Note: there is no
space between year and time) and i am pretty sure zero lenght string
is not a white space.
Please help- Hide quoted text -

- Show quoted text -
 
AllowWhiteSpace means "be flexible with whitespace". Remove that option.

parez said:
Sorry about that!!
Yes i am saying it should fail
Are you saying that you want the parsing to fail in that situation?

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)"parez" <[email protected]>
wrote in message



i have two accepted formats.
expectedFormats = New String() {"%M/%d/yyyy", "%M/%d/yyyy hh:mm:ss
tt"}
dt = DateTime.ParseExact(txtInpDateString.Text, expectedFormats,
culture.DateTimeFormat,
Globalization.DateTimeStyles.AllowWhiteSpaces)
and i get 05/14/200711:22:33 AM as a valid date. (Note: there is no
space between year and time) and i am pretty sure zero lenght string
is not a white space.
Please help- Hide quoted text -

- Show quoted text -
 
Back
Top