[SerializableAttribute] public struct DateTime : IComparable, IFormattable, IConvertible, ISerializable, IComparable<DateTime>, IEquatable<DateTime>
static void Main(string[] args)
{
DateTime newChina = new DateTime(1949, 10, 1);
Console.WriteLine(newChina);
Console.WriteLine("当前时间:");
Console.WriteLine("{0}年,{1}月,{2}日",DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
Console.WriteLine("{0}时,{1}分, {2}秒",DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
Console.WriteLine("三天后:{0}",DateTime.Now.AddDays(3));
Console.ReadLine();
}
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd"));
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
static void Main(string[] args)
{
CultureInfo jaJP = new CultureInfo("ja-JP");
jaJP.DateTimeFormat.Calendar = new JapaneseCalendar();
DateTime date1 = new DateTime(1867, 1, 1);
DateTime date2 = new DateTime(1967, 1, 1);
try
{
Console.WriteLine(date2.ToString(jaJP));
Console.WriteLine(date1.ToString(jaJP));
}
catch (ArgumentOutOfRangeException)
{
Console.WriteLine("{0:d} is earlier than {1:d} or later than {2:d}",
date1,
jaJP.DateTimeFormat.Calendar.MinSupportedDateTime,
jaJP.DateTimeFormat.Calendar.MaxSupportedDateTime);
}
Console.ReadLine();
}
static void Main(string[] args)
{
Console.WriteLine("2000年至2015年中二月的天数");
for (int i = 2000; i < 2015; i++)
{
Console.WriteLine("{0}年2月有:{1}天", i, DateTime.DaysInMonth(i, 2));
}
Console.ReadLine();
}
static void Main(string[] args)
{
Console.WriteLine("2000年至2015年中二月的天数");
for (int i = 2000; i < 2015; i++)
{
if (DateTime.IsLeapYear(i))
Console.WriteLine("{0}年是闰年,2月有{1}天", i, DateTime.DaysInMonth(i, 2));
else
Console.WriteLine("{0}年是平年,2月有{1}天",i,DateTime.DaysInMonth(i,2));
}
Console.ReadLine();
}
// Checks whether a given year is a leap year. This method returns true if
// year is a leap year, or false if not.
//
public static bool IsLeapYear(int year) {
if (year < 1 || year > 9999) {
throw new ArgumentOutOfRangeException("year", Environment.GetResourceString("ArgumentOutOfRange_Year"));
}
Contract.EndContractBlock();
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有