相关操作代码如下:
int year=2011;
int week=1;
Calendar calFirstDayOfTheYear = new GregorianCalendar(year,
Calendar.JANUARY, 1);
calFirstDayOfTheYear.add(Calendar.DATE, 7 * (week-1));
int dayOfWeek = calFirstDayOfTheYear.get(Calendar.DAY_OF_WEEK);
Calendar calFirstDayInWeek = (Calendar)calFirstDayOfTheYear.clone();
calFirstDayInWeek.add(Calendar.DATE,
calFirstDayOfTheYear.getActualMinimum(Calendar.DAY_OF_WEEK) - dayOfWeek);
Date firstDayInWeek = calFirstDayInWeek.getTime();
System.out.println(year + "年第" + week + "个礼拜的第一天是" + ReportDateUtil.getFromatDay().format(firstDayInWeek));
Calendar calLastDayInWeek = (Calendar)calFirstDayOfTheYear.clone();
calLastDayInWeek.add(Calendar.DATE,
calFirstDayOfTheYear.getActualMaximum(Calendar.DAY_OF_WEEK) - dayOfWeek);
Date lastDayInWeek = calLastDayInWeek.getTime();
System.out.println(year + "年第" + week + "个礼拜的最后一天是" + ReportDateUtil.getFromatDay().format(lastDayInWeek));
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。