java 判断周六周日

    DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");               
    String bDate = "2018-05-01"; 
    Date bdate = format1.parse(bDate); 
       Calendar cal = Calendar.getInstance();
       cal.setTime(bdate);

   if(cal.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY

||cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)

  {
    System. out.print("yes");

  }else {

System.out.print("no")

};


同理,今天是周几也可以测试

你可能感兴趣的:(java 判断周六周日)