Example usage for java.util Calendar DAY_OF_WEEK

List of usage examples for java.util Calendar DAY_OF_WEEK

Introduction

In this page you can find the example usage for java.util Calendar DAY_OF_WEEK.

Prototype

int DAY_OF_WEEK

To view the source code for java.util Calendar DAY_OF_WEEK.

Click Source Link

Document

Field number for get and set indicating the day of the week.

Usage

From source file:Main.java

public static boolean isHoliday(Calendar c) {
    final int week = c.get(Calendar.DAY_OF_WEEK);
    return week == Calendar.SUNDAY || week == Calendar.SATURDAY;
}

From source file:Main.java

public static int getDayOfWeek() {
    return Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
}

From source file:Main.java

public static Calendar getMonday(Calendar calendar) {
    while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
        calendar.add(Calendar.DATE, -1);
    }//from   w w  w .j av  a2  s .  co  m

    return calendar;
}

From source file:Main.java

public static final int getCurrentDayOfWeek() {

    return Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1;

}

From source file:Main.java

public static boolean determineAskUserForStart(Calendar calendar) {
    if (calendar.get(Calendar.DAY_OF_WEEK) >= Calendar.WEDNESDAY) {
        return true;
    } else {//from w  w  w.ja v a 2s. c  o m
        return false;
    }
}

From source file:Main.java

public static boolean isWeekend() {
    Calendar now = Calendar.getInstance();
    return (now.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
            || (now.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY);
}

From source file:Main.java

public static int getWeekDay() {
    Calendar date = Calendar.getInstance();
    return date.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY;
}

From source file:Main.java

public static String getDay() {
    return Calendar.getInstance().getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US);
}

From source file:Main.java

public static int getDayOfWeek(Calendar c, boolean startOnSunday) {
    return getConvertedDayOfWeek(c.get(Calendar.DAY_OF_WEEK), startOnSunday);
}

From source file:Main.java

public static Calendar getFirstDayOfWeek() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);//from  ww w . j  a  va2s.c  o  m
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal;
}