public int weekDay(String strStartDate, String strEndDate) { //strStartDate:"2019-10-25",strEndDate:"2019-12-10" SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Calendar clOne = Calendar.getInstance(); Calendar clTwo = Calendar.getInstance(); try { clOne.setTime(df.parse(strStartDate)); clTwo.setTime(df.parse(strEndDate)); } catch (ParseException e) { System.out.println("日期格式非法"); e.printStackTrace(); } int days = 0; while (clOne.compareTo(clTwo) <= 0) { if (clOne.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && clOne.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) days++; clOne.add(Calendar.DAY_OF_MONTH, 1); } return days; }