M
MikeG
Hi,
I want to be able to check that a string is of a desired format
particularly datetime strings.
VB IsDate() function doesn't work becuase it doesn't know what format
my date is supposed to be. E.g. whist '20031010' maybe a valid date if
the expected format is 'yyyyMMdd' it's not valid if the expected
format is 'ddMMyyyy'.
I've looked at using the DataTime.ParseExact(...) because I can then
specify the exact format my date is in.
But I don't want an "exception" to happen becuase this is bad for
performance.
(I'm importing data from large files and need to report formating
problems with line numbers etc. whenever a badly formatted field is
encountered.)
What I want is this VB.NET code:
Function IsDateTimeValidFormat(value As String, format As String) As
Boolean
One idea I had is ... I noticed from the stack trace of the ParseExact
function that it is calling into some private class called
ParseDateTime or somthing like that, could/should I use reflection to
call into this class?
thanks in advance for any help/suggestions,
MikeG
I want to be able to check that a string is of a desired format
particularly datetime strings.
VB IsDate() function doesn't work becuase it doesn't know what format
my date is supposed to be. E.g. whist '20031010' maybe a valid date if
the expected format is 'yyyyMMdd' it's not valid if the expected
format is 'ddMMyyyy'.
I've looked at using the DataTime.ParseExact(...) because I can then
specify the exact format my date is in.
But I don't want an "exception" to happen becuase this is bad for
performance.
(I'm importing data from large files and need to report formating
problems with line numbers etc. whenever a badly formatted field is
encountered.)
What I want is this VB.NET code:
Function IsDateTimeValidFormat(value As String, format As String) As
Boolean
One idea I had is ... I noticed from the stack trace of the ParseExact
function that it is calling into some private class called
ParseDateTime or somthing like that, could/should I use reflection to
call into this class?
thanks in advance for any help/suggestions,
MikeG