星期几

1949年的国庆节(10月1日)是星期六。
    今年(2012)的国庆节是星期一。
    那么,从建国到现在,有几次国庆节正好是星期日呢?1949年的国庆节(10月1日)是星期六。
    今年(2012)的国庆节是星期一。
    那么,从建国到现在,有几次国庆节正好是星期日呢?


public class a101 {
 public a101(){
  int count = 0 ;
  for (int i = 1946; i <= 2012 ; i++) {
   LocalDate  date = LocalDate.of(i, 10, 1);
   String s = String.valueOf(date.getDayOfWeek());
   if (s.equals("SUNDAY")) {
    System.out.println(i);
    count++;
   }
   
  }
  
  System.out.printf("有%d次国庆节正好是周日",count); 
  
 }
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  new a101();
 }
}

猜你喜欢

转载自blog.csdn.net/qq_38930784/article/details/78824186