Example usage for java.util Calendar DECEMBER

List of usage examples for java.util Calendar DECEMBER

Introduction

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

Prototype

int DECEMBER

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

Click Source Link

Document

Value of the #MONTH field indicating the twelfth month of the year in the Gregorian and Julian calendars.

Usage

From source file:MainClass.java

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

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25);
    int dayOfWeek = xmas.get(Calendar.DAY_OF_WEEK); // 6=Friday

    Calendar cal = new GregorianCalendar(2003, Calendar.JANUARY, 1);
    dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // 4=Wednesday
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25);
    Date date = xmas.getTime();//www  . j  av a 2  s.c  o  m
}

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:PairTest2.java

public static void main(String[] args) {
    GregorianCalendar[] birthdays = { new GregorianCalendar(1906, Calendar.DECEMBER, 9), // G. Hopper
            new GregorianCalendar(1815, Calendar.DECEMBER, 10), // A. Lovelace
            new GregorianCalendar(1903, Calendar.DECEMBER, 3), // J. von Neumann
            new GregorianCalendar(1910, Calendar.JUNE, 22), // K. Zuse
    };//from   ww w.ja  v a 2  s . c  o m
    Pair<GregorianCalendar> mm = ArrayAlg.minmax(birthdays);
    System.out.println("min = " + mm.getFirst().getTime());
    System.out.println("max = " + mm.getSecond().getTime());
}

From source file:PriorityQueueTest.java

public static void main(String[] args) {
    PriorityQueue<GregorianCalendar> pq = new PriorityQueue<GregorianCalendar>();
    pq.add(new GregorianCalendar(1906, Calendar.DECEMBER, 9)); // G. Hopper
    pq.add(new GregorianCalendar(1815, Calendar.DECEMBER, 10)); // A. Lovelace
    pq.add(new GregorianCalendar(1903, Calendar.DECEMBER, 3)); // J. von Neumann
    pq.add(new GregorianCalendar(1910, Calendar.JUNE, 22)); // K. Zuse

    System.out.println("Iterating over elements...");
    for (GregorianCalendar date : pq)
        System.out.println(date.get(Calendar.YEAR));
    System.out.println("Removing elements...");
    while (!pq.isEmpty())
        System.out.println(pq.remove().get(Calendar.YEAR));
}

From source file:Main.java

public static void main(String[] args) {
    Calendar now = Calendar.getInstance();
    System.out.println(now.getTime());
    int month = now.get(Calendar.MONTH);
    if (month == Calendar.JANUARY) {
        System.out.println("JANUARY");
    }/*from  w w  w  .  j a  v a  2  s  . c o m*/
    if (month == Calendar.FEBRUARY) {
        System.out.println("FEBRUARY");
    }
    if (month == Calendar.MARCH) {
        System.out.println("MARCH");
    }
    if (month == Calendar.APRIL) {
        System.out.println("APRIL");
    }
    if (month == Calendar.MAY) {
        System.out.println("MAY");
    }
    if (month == Calendar.JUNE) {
        System.out.println("JUNE");
    }
    if (month == Calendar.JULY) {
        System.out.println("JULY");
    }
    if (month == Calendar.AUGUST) {
        System.out.println("AUGUST");
    }
    if (month == Calendar.SEPTEMBER) {
        System.out.println("SEPTEMBER");
    }
    if (month == Calendar.OCTOBER) {
        System.out.println("OCTOBER");
    }
    if (month == Calendar.NOVEMBER) {
        System.out.println("NOVEMBER");
    }
    if (month == Calendar.DECEMBER) {
        System.out.println("DECEMBER");
    }

}

From source file:Main.java

public static boolean isChristmas() {
    setDate(holidayStart, Calendar.DECEMBER, 24);
    setDate(holidayEnd, Calendar.DECEMBER, 27);

    curTime = Calendar.getInstance();

    return curTime.after(holidayStart) && curTime.before(holidayEnd);
}

From source file:Main.java

public static boolean isChristmas() {
    setDate(holidayStart, Calendar.DECEMBER, 24, false);
    setDate(holidayEnd, Calendar.DECEMBER, 26, true);
    curTime = Calendar.getInstance();
    return curTime.after(holidayStart) && curTime.before(holidayEnd);
}

From source file:Util.java

public static Date getSunday(Date today) {
    Calendar cal = Calendar.getInstance();

    cal.setTime(today);//w  w  w .ja va 2 s  .  com

    int dow = cal.get(Calendar.DAY_OF_WEEK);

    while (dow != Calendar.SUNDAY) {
        int date = cal.get(Calendar.DATE);

        int month = cal.get(Calendar.MONTH);

        int year = cal.get(Calendar.YEAR);

        if (date == getMonthLastDate(month, year)) {

            if (month == Calendar.DECEMBER) {
                month = Calendar.JANUARY;

                cal.set(Calendar.YEAR, year + 1);
            } else {
                month++;
            }

            cal.set(Calendar.MONTH, month);

            date = 1;
        } else {
            date++;
        }

        cal.set(Calendar.DATE, date);

        dow = cal.get(Calendar.DAY_OF_WEEK);
    }

    return cal.getTime();
}