Java Christmas Day Check isChristmas()

Here you can find the source of isChristmas()

Description

is Christmas

License

Open Source License

Declaration

public static boolean isChristmas() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;

public class Main {
    static Calendar curTime = Calendar.getInstance();
    static Calendar holidayStart = Calendar.getInstance();
    static Calendar holidayEnd = Calendar.getInstance();

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

        curTime = Calendar.getInstance();

        return curTime.after(holidayStart) && curTime.before(holidayEnd);
    }//  w  w w.jav a2  s .c  om

    static void setDate(Calendar cal, int month, int date) {
        cal.clear();

        cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR));
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.DATE, date);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
    }
}

Related

  1. isChristmas()
  2. isChristmas()
  3. isChristmas()
  4. isChristmas()