Here you can find the source of isWeekend(Date dt)
Parameter | Description |
---|---|
dt | The given Date |
public static boolean isWeekend(Date dt)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { /**/* ww w . java2 s .c om*/ * Check whether a date is a weekend * * @param dt * The given Date * * @return boolean true if weekend, else false */ public static boolean isWeekend(Date dt) { return isSaturday(dt) || isSunday(dt); } /** * Check whether a date is Saturday * * @param dt * The given Date * * @return boolean true if Saturday, else false */ public static boolean isSaturday(Date dt) { Calendar cal = Calendar.getInstance(); cal.setTime(dt); int day = cal.get(Calendar.DAY_OF_WEEK); return (day == Calendar.SATURDAY) ? true : false; } /** * Check whether a date is Sunday * * @param dt * The given Date * * @return boolean true if Sunday, else false */ public static boolean isSunday(Date dt) { Calendar cal = Calendar.getInstance(); cal.setTime(dt); int day = cal.get(Calendar.DAY_OF_WEEK); return (day == Calendar.SUNDAY) ? true : false; } }