is Weekend - Java java.util

Java examples for java.util:Week

Description

is Weekend

Demo Code


//package com.java2s;
import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar calendar = Calendar.getInstance();
        System.out.println(isWeekend(calendar));
    }//w  w  w. j av  a  2 s  .c  o m

    public static boolean isWeekend(Calendar calendar) {
        if (calendar == null) {
            calendar = Calendar.getInstance();
        }
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
        if (dayOfWeek == Calendar.SUNDAY || dayOfWeek == Calendar.SATURDAY) {
            return true;
        }
        return false;
    }
}

Related Tutorials