dateString = "5/01/2009 09:00";
if (DateTime.TryParseExact(dateString, "M/dd/yyyy hh:mm", enUS,
DateTimeStyles.None, out dateValue))
Console.WriteLine("Converted '{0}' to {1} ({2}).", dateString, dateValue,
dateValue.Kind);
else
Console.WriteLine("'{0}' is not in an acceptable format.", dateString);
------解决方案-------------------- ..UP 上面都有了.
------解决方案--------------------
------解决方案-------------------- 小修改一下...
C# code
if (!System.Text.RegularExpressions.Regex.IsMatch("2008-8", @"^[\d]{4}-[\d]{1,2}-[\d]{1,2}$"))
throw new ArgumentException();