Exemplo n.º 1
0
        public virtual void test_plusDaysM1()
        {
            LocalDate date = LocalDate.of(2012, 1, 1);

            for (int i = 0; i < 366 * 4; i++)
            {
                assertEquals(LocalDateUtils.plusDays(date, -1), date.plusDays(-1));
                date = date.plusDays(1);
            }
        }
Exemplo n.º 2
0
        public virtual void test_dayOfYear()
        {
            LocalDate date = LocalDate.of(2012, 1, 1);

            for (int i = 0; i < 366 * 4; i++)
            {
                assertEquals(LocalDateUtils.doy(date), date.DayOfYear);
                date = date.plusDays(1);
            }
        }
Exemplo n.º 3
0
        public virtual void test_daysBetween()
        {
            LocalDate @base = LocalDate.of(2012, 1, 1);
            LocalDate date  = @base;

            for (int i = 0; i < 366 * 8; i++)
            {
                assertEquals(LocalDateUtils.daysBetween(@base, date), date.toEpochDay() - @base.toEpochDay());
                date = date.plusDays(1);
            }
        }
        //-------------------------------------------------------------------------
        public virtual void test_NO_HOLIDAYS()
        {
            HolidayCalendar test = HolidayCalendars.NO_HOLIDAYS;

            LocalDateUtils.stream(LocalDate.of(2011, 1, 1), LocalDate.of(2015, 1, 31)).forEach(date =>
            {
                assertEquals(test.isBusinessDay(date), true);
                assertEquals(test.isHoliday(date), false);
            });
            assertEquals(test.Name, "NoHolidays");
            assertEquals(test.ToString(), "HolidayCalendar[NoHolidays]");
        }
        //-------------------------------------------------------------------------
        public virtual void test_THU_FRI()
        {
            HolidayCalendar test = HolidayCalendars.THU_FRI;

            LocalDateUtils.stream(LocalDate.of(2011, 1, 1), LocalDate.of(2015, 1, 31)).forEach(date =>
            {
                bool isBusinessDay = date.DayOfWeek != THURSDAY && date.DayOfWeek != FRIDAY;
                assertEquals(test.isBusinessDay(date), isBusinessDay);
                assertEquals(test.isHoliday(date), !isBusinessDay);
            });
            assertEquals(test.Name, "Thu/Fri");
            assertEquals(test.ToString(), "HolidayCalendar[Thu/Fri]");
        }
        //-------------------------------------------------------------------------
        public virtual void test_FRI_SAT()
        {
            HolidayCalendar test = HolidayCalendars.FRI_SAT;

            LocalDateUtils.stream(LocalDate.of(2011, 1, 1), LocalDate.of(2015, 1, 31)).forEach(date =>
            {
                bool isBusinessDay = date.DayOfWeek != FRIDAY && date.DayOfWeek != SATURDAY;
                assertEquals(test.isBusinessDay(date), isBusinessDay);
                assertEquals(test.isHoliday(date), !isBusinessDay);
            });
            assertEquals(test.Name, "Fri/Sat");
            assertEquals(test.ToString(), "HolidayCalendar[Fri/Sat]");
        }
        //-------------------------------------------------------------------------
        public virtual void test_SAT_SUN()
        {
            HolidayCalendar test = HolidayCalendars.SAT_SUN;

            LocalDateUtils.stream(LocalDate.of(2011, 1, 1), LocalDate.of(2015, 1, 31)).forEach(date =>
            {
                bool isBusinessDay = date.DayOfWeek != SATURDAY && date.DayOfWeek != SUNDAY;
                assertEquals(test.isBusinessDay(date), isBusinessDay);
                assertEquals(test.isHoliday(date), !isBusinessDay);
            });
            assertEquals(test.Name, "Sat/Sun");
            assertEquals(test.ToString(), "HolidayCalendar[Sat/Sun]");
        }
        /// <summary>
        /// Resolves this adjustment using the specified reference data, returning an adjuster.
        /// <para>
        /// This returns a <seealso cref="DateAdjuster"/> that performs the same calculation as this adjustment.
        /// It binds the holiday calendar, looked up from the reference data, into the result.
        /// As such, there is no need to pass the reference data in again.
        /// </para>
        /// <para>
        /// The resulting adjuster will be <seealso cref="#normalized() normalized"/>.
        ///
        /// </para>
        /// </summary>
        /// <param name="refData">  the reference data, used to find the holiday calendar </param>
        /// <returns> the adjuster, bound to a specific holiday calendar </returns>
        public DateAdjuster resolve(ReferenceData refData)
        {
            HolidayCalendar holCalAdj = adjustment.Calendar.resolve(refData);

            if (calendar == HolidayCalendarIds.NO_HOLIDAYS)
            {
                BusinessDayConvention adjustmentConvention = adjustment.Convention;
                return(date => adjustmentConvention.adjust(LocalDateUtils.plusDays(date, days), holCalAdj));
            }
            HolidayCalendar       holCalAdd            = calendar.resolve(refData);
            BusinessDayConvention adjustmentConvention = adjustment.Convention;

            return(date => adjustmentConvention.adjust(holCalAdd.shift(date, days), holCalAdj));
        }
Exemplo n.º 9
0
 public override int daysBetween(LocalDate startInclusive, LocalDate endExclusive)
 {
     return(Math.toIntExact(LocalDateUtils.daysBetween(startInclusive, endExclusive)));
 }