public class Demo {
public static void main(String[] args) {
Calendar c=Calendar.getInstance();
int count=0;
for(int i=0;i<365;i++){
c.add(Calendar.DATE, 1);
int dayOfWek =c.get(Calendar.DAY_OF_WEEK);
int day=c.get(Calendar.DAY_OF_MONTH);
int month=c.get(Calendar.MONTH)+1;
int year=c.get(Calendar.YEAR);
if(dayOfWek==1||dayOfWek==7){
count++;
System.out.println(year+":"+month+":"+day+":"+dayOfWek+":"+count);//验证结果
}
}
}
}怎么让calendar是设置到当前时期?
|
|