我有以下方法来验证字符串是否是有效的日期时间:
public bool isDate(string date)
{
bool check = false;
try
{
DateTime converted_date = Convert.ToDateTime(date);
check = true;
}
catch (Exception)
{
check = false;
}
return check;
}
现在,每当我尝试传递这样的字符串时,都会捕获异常“字符串未被识别为有效日期时间”:
“2013 年 12 月 31 日上午 12:00:00”
我不明白为什么会这样。有人可以帮我解决这个问题吗?