DateTime dt = DateTime.Now;
StringBuilder sb = new StringBuilder(); sb. AppendLine(string. Format("DataTime string represents: {0}", dt. ToString()));
sb. AppendLine(string. Format("Year portion of DataTime: {0}", dt. Year)); sb. AppendLine(string. Format("Month part of DataTime: {0}", dt. Month)); sb. AppendLine(string. Format("Date portion of DataTime: {0}", dt. Date)); sb. AppendLine(string. Format("Hourly part of DataTime: {0}", dt. Hour)); sb. AppendLine(string. Format("Minute portion of DataTime: {0}", dt. Minute)); sb. AppendLine(string. Format("Second part of DataTime: {0}", dt. Second)); sb. AppendLine(string. format("millisecond portion of DataTime: {0}", dt. Millisecond));
sb. AppendLine(string. Format("DataTime is the day of the month: {0}", dt. Day)); sb. AppendLine(string. Format("DataTime is the day of the week: {0}", dt. DayOfWeek)); sb. AppendLine(string. Format("DataTime is the day of the year: {0}", dt. DayOfYear)); sb. AppendLine(string. Format("DataTime gets the time portion of the day (TimeSpan format): {0}", dt. TimeOfDay));
sb. AppendLine(string. Format("DateTime converts to 64-bit binary: {0}", dt. ToBinary())); sb. AppendLine(string. Format("DateTime to Windows File Time: {0}", dt. ToFileTime())); sb. AppendLine(string. Format("DateTime to UTC Windows File Time: {0}", dt. ToFileTimeUtc())); sb. AppendLine(string. Format("DateTime converts to local time: {0}", dt. ToLocalTime())); sb. AppendLine(string. Format("DateTime converted to OLE automation date: {0}", dt. ToOADate())); sb. AppendLine(string. Format("DateTime to UTC Time: {0}", dt. ToUniversalTime()));
sb. AppendLine(string. Format("DateTime converts to long date form: {0}", dt. ToLongDateString())); sb. AppendLine(string. Format("DateTime converts to short date form: {0}", dt. ToShortDateString())); sb. AppendLine(string. Format("DateTime converts to long-term form: {0}", dt. ToLongTimeString())); sb. AppendLine(string. Format("DateTime converts to short-time form: {0}", dt. ToShortTimeString()));
Console.WriteLine(sb. ToString());
|