|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Reflection;
|
namespace wcftest
|
{
|
/// <summary>
|
/// 日期处理类
|
/// </summary>
|
public class DateTimeHelper
|
{
|
/// <summary>
|
/// 转换日期格式为字符串
|
/// </summary>
|
/// <typeparam name="T"></typeparam>
|
/// <returns></returns>
|
public static string ConvertToString(DateTime? dt)
|
{
|
if (dt == null)
|
{
|
return string.Empty;
|
}
|
return Convert.ToDateTime(dt).ToString("yyyy-MM-dd HH:mm:ss");
|
}
|
|
/// <summary>
|
/// 转换日期格式为字符串
|
/// </summary>
|
/// <typeparam name="T"></typeparam>
|
/// <returns></returns>
|
public static string ConvertToStringForOnlyShowTime(DateTime? dt)
|
{
|
if (dt == null)
|
{
|
return string.Empty;
|
}
|
return Convert.ToDateTime(dt).ToString("HH:mm:ss");
|
}
|
}
|
}
|