is a Date Weekend - Android java.util

Android examples for java.util:Week

Description

is a Date Weekend

Demo Code

import android.util.Log;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Main{

    public static boolean isWeekend(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);/*ww  w . ja  v a  2  s  .  c  om*/

        int week = calendar.get(Calendar.DAY_OF_WEEK);
        if (week == 1 || week == 7) {
            return true;
        }

        return false;
    }

}

Related Tutorials