Determine whether a date is a Saturday, Sunday

public static boolean isWeekend(String date) throws ParseException{
		DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");       
		Date bdate = format1.parse(date);
		Calendar cal = Calendar.getInstance();
		cal.setTime(bdate);
		if(cal.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY||cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
			return true;
		}
		else return false;
	}

Published 87 original articles · won praise 22 · views 190 000 +

Guess you like

Origin blog.csdn.net/gaofenglxx/article/details/60140083