增加判断字符串是否为指定时间格式的方法。
This commit is contained in:
parent
90bdb831c7
commit
a8c13892dc
|
@ -72,5 +72,22 @@ namespace Falcon.SugarApi
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回字符串是否为指定格式的日期时间格式
|
||||
/// </summary>
|
||||
/// <param name="str">给定字符串</param>
|
||||
/// <param name="dateFormat">日期时间格式</param>
|
||||
/// <returns>是True,否False</returns>
|
||||
/// <exception cref="ArgumentNullException">参数为空</exception>
|
||||
public static bool IsDateFormat(this string str, string dateFormat) {
|
||||
if (str.IsNullOrEmpty()) {
|
||||
throw new ArgumentNullException(nameof(str));
|
||||
}
|
||||
if (dateFormat.IsNullOrEmpty()) {
|
||||
throw new ArgumentNullException(nameof(dateFormat));
|
||||
}
|
||||
return str.TryToDateTime(dateFormat, out var _);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user