|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
有时也搞不懂应该学那种;主要看你以后去的那个公司是使用哪种了。就像王千祥的课上说的:企业应用现在主要就三层(其实也差不多就是MVC):表示层(主要使用html写的,很简单)、业务逻辑层(主要就是应用服务器的)。最后就是数据层(其实就是学习数据库)publicenumDateInterval
{
Second,Minute,Hour,Day,Week,Month,Quarter,Year
}
publicsealedclassDateTimeManger
{
privateDateTimeManger()
{}//endofdefaultconstructor
publicstaticlongDateDiff(DateIntervalInterval,System.DateTimeStartDate,System.DateTimeEndDate)
{
longlngDateDiffValue=0;
System.TimeSpanTS=newSystem.TimeSpan(EndDate.Ticks-StartDate.Ticks);
switch(Interval)
{
caseDateInterval.Second:
lngDateDiffValue=(long)TS.TotalSeconds;
break;
caseDateInterval.Minute:
lngDateDiffValue=(long)TS.TotalMinutes;
break;
caseDateInterval.Hour:
lngDateDiffValue=(long)TS.TotalHours;
break;
caseDateInterval.Day:
lngDateDiffValue=(long)TS.Days;
break;
caseDateInterval.Week:
lngDateDiffValue=(long)(TS.Days/7);
break;
caseDateInterval.Month:
lngDateDiffValue=(long)(TS.Days/30);
break;
caseDateInterval.Quarter:
lngDateDiffValue=(long)((TS.Days/30)/3);
break;
caseDateInterval.Year:
lngDateDiffValue=(long)(TS.Days/365);
break;
}
return(lngDateDiffValue);
}//endofDateDiff
}//endofclass
Samples:
publicclassDateDiffCS
{
publicstaticvoidMain(string[]CmdLineArgs)
{
System.DateTimedate1=System.DateTime.Now;
System.DateTimedate2=System.DateTime.Now.AddYears(2);
System.Console.Out.WriteLine("Days:"+DateTimeManger.DateDiff
(DateTimeManger.DateInterval.Day,date1,date2).ToString());
System.Console.Out.WriteLine("Hours:"+DateTimeManger.DateDiff
(DateTimeManger.DateInterval.Hour,date1,date2).ToString());
System.Console.Out.WriteLine("Minutes:"+DateTimeManger.DateDiff
(DateTimeManger.DateInterval.Minute,date1,date2).ToString());
System.Console.Out.WriteLine("Month:"+DateTimeManger.DateDiff
(DateTimeManger.DateInterval.Month,date1,date2).ToString());
System.Console.Out.WriteLine("Quarter:"+DateTimeManger.DateDiff
(DateTimeManger.DateInterval.Quarter,date1,date2).ToString());
System.Console.Out.WriteLine("Seconds:"+DateTimeManger.DateDiff
(DateTimeManger.DateInterval.Second,date1,date2).ToString());
System.Console.Out.WriteLine("Week:"+DateTimeManger.DateDiff
(DateTimeManger.DateInterval.Week,date1,date2).ToString());
System.Console.Out.WriteLine("Year:"+DateTimeManger.DateDiff
(DateTimeManger.DateInterval.Year,date1,date2).ToString());
System.Console.In.ReadLine();
}
}//endoftheclass
From:
HP.Mahesh.UtilityManager.Libraries.DateTimeUtility
Java欺骗了我们那么多年,如今的多核时代,我认为它气数已尽! |
|