#region 时间格式转换为yyyy-mm-dd hh:mm:ss.fff
/// <summary>
/// 时间格式转换为yyyy-mm-dd hh:mm:ss.fff
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string ConvertDateTime(object obj)
{
if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
{
try
{
return ((System.DateTime)(obj)).ToString("yyyy-MM-dd HH:mm:ss.fff");
}
catch
{
return string.Empty;
}
}
return string.Empty;
}
#endregion
#region 时间格式转换为yyyy-mm-dd hh:mm:ss.fff
/// <summary>
/// 时间格式转换为yyyy-mm-dd
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string ConvertShortDateTime(object obj)
{
if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
{
try
{
return ((System.DateTime)(obj)).ToString("yyyy-MM-dd");
}
catch
{
return string.Empty;
}
}
return string.Empty;
}
#endregion