通过月份字符串yyyy-MM获得DateTime?
2017-01-25 17:23:17 访问(1329) 赞(0) 踩(0)
/// <summary>
/// 通过月份字符串yyyy-MM获得DateTime?
/// </summary>
/// <param name="obj"></param>
/// <param name="defaultValue"></param>
/// <returns></returns>
public DateTime? GetDateTimeNullByStrMonth(string str, DateTime? defaultValue)
{
if (str == null || str.Length == 0)
return null;
DateTime theResult = DateTime.MinValue;
if (DateTime.TryParse(str + "-01", out theResult))
return theResult;
return defaultValue;
}
标签:
通过月份字符串yyyy-MM获得DateTime? 


上一条:
下一条:
相关评论
发表评论