Exemple #1
0
 /// <summary>
 /// 将DateTime类型转换为yyyyMMdd类型,如果传入的DateTime不能转换为String,返回空字符串
 /// </summary>
 /// <param name="dTime"></param>
 /// <returns></returns>
 public static string ToDateTimeString(string dTime)
 {
     return(ToDateTimeString(SafeConvert.ToDateTime(dTime), TimeFormatEnum.DateTimeName));
 }
Exemple #2
0
 /// <summary>
 /// 将DateTime类型转换为yyyy-MM-dd HH:mm:ss.fff类型,如果传入的DateTime不能转换为String,返回空字符串
 /// </summary>
 /// <param name="dTime">待转换DateTime</param>
 /// <returns>返回String类型值,如果传入的DateTime不能转换为String,返回空字符串</returns>
 public static string ToDateTimeWithMilliseconds(DateTime?dTime)
 {
     return(ToDateTimeString(SafeConvert.ToDateTime(dTime), TimeFormatEnum.Milliseconds));
 }
Exemple #3
0
 /// <summary>
 /// 将DateTime类型转换为HH:mm:ss类型,如果传入的DateTime不能转换为String,返回空字符串
 /// </summary>
 /// <param name="dTime">待转换DateTime</param>
 /// <returns>返回String类型值,如果传入的DateTime不能转换为String,返回空字符串</returns>
 public static string ToTime(DateTime?dTime)
 {
     return(ToDateTimeString(SafeConvert.ToDateTime(dTime), TimeFormatEnum.Time));
 }
Exemple #4
0
 /// <summary>
 /// 将DateTime类型转换为String类型,如果传入的DateTime不能转换为String,返回空字符串
 /// </summary>
 /// <param name="dTime">待转换DateTime</param>
 /// <returns>返回String类型值,如果传入的DateTime不能转换为String,返回空字符串</returns>
 public static string ToDateTimeString(DateTime?dTime, TimeFormatEnum timeFormatEnum)
 {
     return(ToDateTimeString(SafeConvert.ToDateTime(dTime), timeFormatEnum));
 }