GregorianCalendar公里类

使用GregorianCalendar 获得日期是年中第几周第几天

public class Common
{
/// <summary>
/// 获取日期是年中的第几周
/// </summary>
/// <param name="dtime"></param>
/// <returns></returns>
public static int GetWeekIndexOfYear(DateTime dtime)
{
GregorianCalendar gc = new GregorianCalendar();
int weekOfYear = gc.GetWeekOfYear(dtime, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
return weekOfYear;
} /// <summary>
/// 获取日期是本周的第几天
/// </summary>
/// <param name="dtime"></param>
/// <returns></returns>
public static DayOfWeek GetDateIndexOfWeekAndMonth(DateTime dtime, out int indexOfMonth)
{
GregorianCalendar gc = new GregorianCalendar();
indexOfMonth = gc.GetDayOfMonth(dtime);
DayOfWeek dayOfWeek = gc.GetDayOfWeek(dtime);
return dayOfWeek;
}
}
上一篇:UI- Layer的使用总结(附动画)


下一篇:oracle表的统计信息完全正确,执行计划无故改变。原厂人员如是回复