Here you can find the source of isOnWeekend(Date date)
Parameter | Description |
---|---|
date | date to be checked |
public static boolean isOnWeekend(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { /**//from w ww . j av a2 s . c om * Uses the {@link Calendar} to see of the day of week is equal to saturday or sunday. * @param date date to be checked * @return return true only if the data falls on a saturday or a sunday. */ public static boolean isOnWeekend(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return ((cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) || (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)); } }