Custom Date Format Validation

Hi all,

Hope there is a quick and easy answer to this. I want to be able to check that a custom datetime format string only contains valid characters in a valid order (ie "dd/MM/yyyy" and not something like "dM/yMM/yymzq"). I thought trying DateTime.Now.ToString(formatstring) would throw an exception if formatstring = "somegarbageformat", but it does not.

I guess some crazy regular expression could be set up but I imagine this would be overly complicated (to cater for all possible datetime formats).

Regards,

Mark.

[580 byte] By [spanky4_3] at [2007-12-26]

.NET Development

Site Classified