Java Calendar Day isHolyday(Calendar c)

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

Description

is Holyday

License

Open Source License

Declaration

public static boolean isHolyday(Calendar c) 

Method Source Code

//package com.java2s;
/**/* www  . j  a v a 2s.  c  o m*/
 * This file is part of JEMMA - http://jemma.energy-home.org
 * (C) Copyright 2013 Telecom Italia (http://www.telecomitalia.it)
 *
 * JEMMA is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License (LGPL) version 3
 * or later as published by the Free Software Foundation, which accompanies
 * this distribution and is available at http://www.gnu.org/licenses/lgpl.html
 *
 * JEMMA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License (LGPL) for more details.
 *
 */

import java.util.Calendar;

public class Main {
    private static int easterDay, easterMonth, mondayEasterDay, mondayEasterMonth;

    public static boolean isHolyday(Calendar c) {
        int month = c.get(Calendar.MONTH);
        int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);

        if (month == Calendar.JANUARY) {
            if (dayOfMonth == 1)
                return true; // Capodanno
            if (dayOfMonth == 6)
                return true; // Epifania
        }
        if (month == Calendar.APRIL && dayOfMonth == 25)
            return true; // Liberazione Italia
        if (month == Calendar.MAY && dayOfMonth == 1)
            return true; // Festa del lavoro
        if (month == Calendar.JUNE && dayOfMonth == 2)
            return true; // Festa della Repubblica Italia
        if (month == Calendar.AUGUST && dayOfMonth == 15)
            return true; // Assunzione
        if (month == Calendar.NOVEMBER && dayOfMonth == 1)
            return true; // Ognissanti
        if (month == Calendar.DECEMBER) {
            if (dayOfMonth == 8)
                return true; // Immacolata Concezione
            if (dayOfMonth == 25)
                return true; // Natale
            if (dayOfMonth == 26)
                return true; // Santo Stefano
        }
        if (month == easterMonth && dayOfMonth == easterDay)
            return true; // Pasqua
        if (month == mondayEasterMonth && dayOfMonth == mondayEasterDay)
            return true; // Pasquetta

        return false;
    }
}

Related

  1. isAllDayEvent(Calendar dtStart, Calendar dtEnd)
  2. isBusinessDay(Calendar cal)
  3. isDayAfter(Calendar calendar, Calendar baseCalendar)
  4. isDSTChangeDay(Calendar cal)
  5. isEndOfDay(Calendar calendar)
  6. isRestDay(Calendar cal)
  7. isSameDay(Calendar c1, Calendar c2)
  8. isSameDay(Calendar cal1, Calendar cal2)
  9. isSameDay(Calendar cal1, Calendar cal2)