您当前位置:编程帮手 > 知识 > 知识 > C# > 常用代码 > 内容
代码库
2017-07-07 14:57:57 访问(1355) 赞(0) 踩(0)
/// <summary> /// DateTime的内容输出 /// </summary> /// <param name="str"></param> /// <returns></returns> public string DateTimeMethodOutput(string str) { DateTime dt = DateTime.Now; if (str != null && str.Length > 0) { dt = DateTime.Parse(str); } StringBuilder theResult = new StringBuilder(); theResult.AppendLine("dt.ToString() = " + dt.ToString()); theResult.AppendLine("dt.Year.ToString() = " + dt.Year.ToString()); theResult.AppendLine("dt.Month.ToString() = " + dt.Month.ToString()); theResult.AppendLine("dt.Day.ToString() = " + dt.Day.ToString()); theResult.AppendLine("dt.Hour.ToString() = " + dt.Hour.ToString()); theResult.AppendLine("dt.Minute.ToString() = " + dt.Minute.ToString()); theResult.AppendLine("dt.Second.ToString() = " + dt.Second.ToString()); theResult.AppendLine("dt.Millisecond.ToString() = " + dt.Millisecond.ToString()); theResult.AppendLine("dt.DayOfWeek.ToString() = " + dt.DayOfWeek.ToString()); theResult.AppendLine("dt.DayOfYear.ToString() = " + dt.DayOfYear.ToString()); theResult.AppendLine("dt.Date.ToString() = " + dt.Date.ToString()); theResult.AppendLine("dt.Kind.ToString() = " + dt.Kind.ToString()); theResult.AppendLine("dt.Ticks.ToString() = " + dt.Ticks.ToString()); theResult.AppendLine("dt.TimeOfDay.ToString() = " + dt.TimeOfDay.ToString()); theResult.AppendLine("dt.ToFileTime().ToString() = " + dt.ToFileTime().ToString()); theResult.AppendLine("dt.ToBinary().ToString() = " + dt.ToBinary().ToString()); theResult.AppendLine("dt.ToFileTimeUtc().ToString() = " + dt.ToFileTimeUtc().ToString()); theResult.AppendLine("dt.ToLocalTime().ToString() = " + dt.ToLocalTime().ToString()); theResult.AppendLine("dt.ToLongDateString() = " + dt.ToLongDateString()); theResult.AppendLine("dt.ToLongTimeString() = " + dt.ToLongTimeString()); theResult.AppendLine("dt.ToOADate().ToString() = " + dt.ToOADate().ToString()); theResult.AppendLine("dt.ToShortDateString() = " + dt.ToShortDateString()); theResult.AppendLine("dt.ToShortTimeString() = " + dt.ToShortTimeString()); theResult.AppendLine("dt.ToUniversalTime().ToString() = " + dt.ToUniversalTime().ToString()); theResult.AppendLine("dt.IsDaylightSavingTime().ToString() = " + dt.IsDaylightSavingTime().ToString()); theResult.AppendLine("dt.GetTypeCode().ToString() = " + dt.GetTypeCode().ToString()); return theResult.ToString(); }
上一条:
下一条: