Java Calendar Week isWeekEnd(Calendar c)

Here you can find the source of isWeekEnd(Calendar c)

Description

is Week End

License

Open Source License

Declaration

public static boolean isWeekEnd(Calendar c) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {
    public static boolean isWeekEnd(Calendar c) {
        int day = c.get(Calendar.DAY_OF_WEEK);
        if (day == Calendar.SUNDAY || day == Calendar.SATURDAY) {
            return true;
        }/*from  ww w .  ja  v a  2 s  .c  o  m*/
        return false;
    }

    public static boolean isWeekEnd(String date) {
        return isWeekEnd(parseCalendar(date));
    }

    public static Calendar parseCalendar(String s) {
        Calendar c = Calendar.getInstance();
        try {
            int d = Integer.parseInt(s);
            int year = d / 10000;
            int month = (d % 10000) / 100;
            int day = d % 100;
            c.set(year, month - 1, day);
        } catch (Exception e) {
            return null;
        }
        return c;
    }
}

Related

  1. getWeekEnd(boolean startSunday, Calendar date)
  2. getWeekOfCurrentDayWithoutStartShift(Calendar cal)
  3. getWeekStart(boolean startSunday, Calendar date)
  4. isThisWeek(Calendar time)
  5. isWeekday(Calendar cal)
  6. isWeekend(Calendar cal)
  7. isWeekend(GregorianCalendar date)
  8. lastDayOfWeek(Calendar cal)
  9. lastDayOfWeek(Calendar calendar)