Class CalendarUtil


  • public class CalendarUtil
    extends Object
    Utility class for date operations.
    Version:
    $Id: $
    Author:
    Sven Diedrichsen
    • Constructor Detail

      • CalendarUtil

        public CalendarUtil()
    • Method Detail

      • create

        public LocalDate create()
        Creates the current date within the gregorian calendar.
        Returns:
        today
      • create

        public LocalDate create​(int year,
                                int month,
                                int day)
        Creates the date within the ISO chronology.
        Parameters:
        year - a int.
        month - a int.
        day - a int.
        Returns:
        date
      • create

        public ChronoLocalDate create​(int year,
                                      int month,
                                      int day,
                                      Chronology chronology)
        Creates the date within the provided chronology.
        Parameters:
        year - a int.
        month - a int.
        day - a int.
        chronology - the chronology to use
        Returns:
        date the LocalDate
      • isWeekend

        public boolean isWeekend​(LocalDate date)
        Returns if this date is on a wekkend.
        Parameters:
        date - a LocalDate object.
        Returns:
        is weekend
      • getIslamicHolidaysInGregorianYear

        public Stream<LocalDate> getIslamicHolidaysInGregorianYear​(int gregorianYear,
                                                                   int islamicMonth,
                                                                   int islamicDay)
        Returns a set of gregorian dates within a gregorian year which equal the islamic month and day. Because the islamic year is about 11 days shorter than the gregorian there may be more than one occurrence of an islamic date in an gregorian year. i.e.: In the gregorian year 2008 there were two 1/1. They occurred on 1/10 and 12/29.
        Parameters:
        gregorianYear - a int.
        islamicMonth - a int.
        islamicDay - a int.
        Returns:
        List of gregorian dates for the islamic month/day.
      • getRelativeIslamicHolidaysInGregorianYear

        public Set<LocalDate> getRelativeIslamicHolidaysInGregorianYear​(int gregorianYear,
                                                                        int islamicMonth,
                                                                        int islamicDay,
                                                                        int relativeShift)
        Returns a set of gregorian dates within a gregorian year which equal the islamic month and day with a relative shift. Because the islamic year is about 11 days shorter than the gregorian there may be more than one occurrence of an islamic date in an gregorian year. i.e.: In the gregorian year 2008 there were two 1/1. They occurred on 1/10 and 12/29.
        Parameters:
        gregorianYear - a int.
        islamicMonth - a int.
        islamicDay - a int.
        relativeShift - a int.
        Returns:
        List of gregorian dates for the islamic month/day shifted by relative shift days.
      • getEthiopianOrthodoxHolidaysInGregorianYear

        public Stream<LocalDate> getEthiopianOrthodoxHolidaysInGregorianYear​(int gregorianYear,
                                                                             int eoMonth,
                                                                             int eoDay)
        Returns a set of gregorian dates within a gregorian year which equal the ethiopian orthodox month and day. Because the ethiopian orthodox year different from the gregorian there may be more than one occurrence of an ethiopian orthodox date in an gregorian year.
        Parameters:
        gregorianYear - a int.
        eoMonth - a int.
        eoDay - a int.
        Returns:
        List of gregorian dates for the ethiopian orthodox month/day.
      • contains

        public boolean contains​(Set<Holiday> holidays,
                                LocalDate date,
                                HolidayType holidayType)
        Shows if the requested date is contained in the Set of holidays.
        Parameters:
        holidays - a Set object.
        date - a LocalDate object.
        holidayType - a HolidayType object
        Returns:
        contains this date
      • contains

        public boolean contains​(Set<Holiday> holidays,
                                LocalDate date)
        Calls #contains(holidays, date, null)
        Parameters:
        holidays - the holidays to search through
        date - the date to look for
        Returns:
        the date is contained in the set of holidays