2014-06-07 07:24:28
来 源
中存储网
安装配置
oracle查看当前日期是第几个星期方法的代码段,需要的兄弟姐妹可以参考一下
系统当前时间是多少周,就是是今年的第几个星期
 相关操作代码如下:

 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));

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。