Example usage for java.util Calendar SUNDAY

List of usage examples for java.util Calendar SUNDAY

Introduction

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

Prototype

int SUNDAY

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

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Sunday.

Usage

From source file:Main.java

public static void main(String[] args) {
    int dayOfWeek = Calendar.SUNDAY;
    Calendar cal = new GregorianCalendar();
    cal.set(2015, 0, 1, 0, 0);/*from   ww w. ja  va2  s  .  co m*/
    cal.set(Calendar.DAY_OF_WEEK, dayOfWeek);
    while (cal.get(Calendar.YEAR) == 2015) {
        System.out.println(cal.getTime());
        cal.add(Calendar.DAY_OF_MONTH, 7);
    }
}

From source file:Test.java

public static void main(String[] args) {
    SimpleTimeZone simpleTimeZone = new SimpleTimeZone(-21600000, "CST", Calendar.MARCH, 1, -Calendar.SUNDAY,
            7200000, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 7200000, 3600000);

    System.out.println(simpleTimeZone.getDisplayName() + " - " + simpleTimeZone.observesDaylightTime());

}

From source file:Main.java

public static void main(String args[]) {

    SimpleTimeZone stobj = new SimpleTimeZone(-28800000, "India", Calendar.MAY, 1, -Calendar.SUNDAY, 7200000,
            Calendar.OCTOBER, -1, Calendar.MONDAY, 7200000, 3600000);

    // setting DST saving time
    stobj.setDSTSavings(5400000);/*w  w  w.j  a va  2  s .co  m*/

    // checking the value      
    System.out.println("DST saving value : " + stobj.getDSTSavings());
}

From source file:Main.java

public static void main(String args[]) {

    SimpleTimeZone stobj = new SimpleTimeZone(-28800000, "America/Los_Angeles", Calendar.AUGUST, 1,
            -Calendar.SUNDAY, 7200000, Calendar.DECEMBER, -1, Calendar.SUNDAY, 7200000, 3600000);

    // checking the initial value      
    System.out.println("Initial value : " + stobj);

    // setting end rule
    stobj.setEndRule(Calendar.MAY, 2, Calendar.TUESDAY, 3600000);

    // checking the new value      
    System.out.println("New value : " + stobj);
}

From source file:Main.java

public static void main(String[] args) {
    Calendar now = Calendar.getInstance();
    System.out.println(now.getTime());

    int dayOfWeek = now.get(Calendar.DAY_OF_WEEK);
    if (Calendar.SUNDAY == dayOfWeek) {
        System.out.println("SUNDAY");
    }//from w w w.  j  a  v a  2s  .c o m
    if (Calendar.MONDAY == dayOfWeek) {
        System.out.println("MONDAY");
    }
    if (Calendar.TUESDAY == dayOfWeek) {
        System.out.println("TUESDAY");
    }
    if (Calendar.WEDNESDAY == dayOfWeek) {
        System.out.println("WEDNESDAY");
    }
    if (Calendar.THURSDAY == dayOfWeek) {
        System.out.println("THURSDAY");
    }
    if (Calendar.FRIDAY == dayOfWeek) {
        System.out.println("FRIDAY");
    }
    if (Calendar.SATURDAY == dayOfWeek) {
        System.out.println("SATURDAY");
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    Calendar cal = Calendar.getInstance();
    Date now = new Date();
    cal.setTime(now);//from  w w w.  ja v a 2  s  .  c  o m
    int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
    if (dayofweek == Calendar.SUNDAY)
        System.out.println("SUNDAY");
    if (dayofweek == Calendar.MONDAY)
        System.out.println("MONDAY");
    if (dayofweek == Calendar.TUESDAY)
        System.out.println("TUESDAY");
    if (dayofweek == Calendar.WEDNESDAY)
        System.out.println("WEDNESDAY");
    if (dayofweek == Calendar.THURSDAY)
        System.out.println("THURSDAY");
    if (dayofweek == Calendar.FRIDAY)
        System.out.println("FRIDAY");
    if (dayofweek == Calendar.SATURDAY) {
        System.out.println("SATURDAY");
    }
}

From source file:Main.java

public static void main(String[] args) {
    Calendar calendar = Calendar.getInstance();

    // 15-04-2012
    calendar.set(Calendar.DAY_OF_MONTH, 15);
    calendar.set(Calendar.YEAR, 2012);
    calendar.set(Calendar.HOUR, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MONTH, 3);
    Date start = calendar.getTime();

    // 15-06-2012
    calendar.set(Calendar.MONTH, 5);
    Date end = calendar.getTime();

    calendar.setTime(start);/*from  w w w . ja v a2 s.c  om*/
    Date d = null;
    while ((d = calendar.getTime()).before(end) || d.equals(end)) {
        int day = calendar.get(Calendar.DAY_OF_WEEK);
        if (day != Calendar.SATURDAY && day != Calendar.SUNDAY) {
            System.out.println(d);
        }
        calendar.add(Calendar.DAY_OF_MONTH, 1);
    }
}

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 getWeekDay() {
    Calendar date = Calendar.getInstance();
    return date.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY;
}

From source file:Main.java

public static int getServiceIdForDay(int day) {
    switch (day) {
    case Calendar.SUNDAY: {
        return 3;
    }/*from   w w w .  j  a  v a2 s.  co m*/
    case Calendar.SATURDAY: {
        return 2;
    }
    default: { // this will cover any days not specifically called out
        return 1;
    }
    }
}