- Calendar c1=Calendar.getInstance();
- c1.set(2012,6,10);
- int count=0;
- Calendar c=Calendar.getInstance();
- while(c.get(Calendar.DAY_OF_YEAR)<=c1.get(Calendar.DAY_OF_YEAR)) //1.修改
- {
- if( c.get(Calendar.DAY_OF_WEEK)>1 && c.get(Calendar.DAY_OF_WEEK)<7) //2.修改,星期是从星期日(值为1)开始的
- {
- count++;
- }
- c.add(Calendar.DAY_OF_MONTH,1);
- }
- System.out.println(count+"天");
复制代码 |