/* (non-Javadoc)
@see net.finmath.time.daycount.DayCountConventionInterface#getDaycount(org.threeten.bp.LocalDate, org.threeten.bp.LocalDate)
483242
@Override
	public double getDaycount(LocalDate startDate, LocalDate endDate) {
		if(startDate.isAfter(endDate)) {
			return -getDaycount(endDate,startDate);
		}

		int startDateDay 	= startDate.getDayOfMonth();
		int startDateMonth 	= startDate.getMonthValue();
		int startDateYear 	= startDate.getYear();

		int endDateDay 		= endDate.getDayOfMonth();
		int endDateMonth 	= endDate.getMonthValue();
		int endDateYear 	= endDate.getYear();

		if(
				isEndOfMonth &&
				startDate.getMonth() == Month.FEBRUARY &&
				startDate.getDayOfMonth() == startDate.lengthOfMonth() &&
				endDate.getMonth() == Month.FEBRUARY &&
				endDate.getDayOfMonth() == endDate.lengthOfMonth()
				) {
			endDateDay = 30;
		}

		if(
				isEndOfMonth &&
				startDate.getMonth() == Month.FEBRUARY &&
				startDate.getDayOfMonth() == startDate.lengthOfMonth()
				) {
			startDateDay = 30;
		}

		if(endDateDay > 30 && startDateDay >= 30) {
			endDateDay = 30;
		}
		startDateDay = Math.min(startDateDay,30);

		return (endDateYear - startDateYear) * 360.0 + (endDateMonth - startDateMonth) * 30.0 + (endDateDay - startDateDay);
	}
954579
private void readDay(ProjectCalendar calendar, Project.Calendars.Calendar.WeekDays.WeekDay day, boolean readExceptionsFromDays)
   {
      BigInteger dayType = day.getDayType();
      if (dayType != null)
      {
         if (dayType.intValue() == 0)
         {
            if (readExceptionsFromDays)
            {
               readExceptionDay(calendar, day);
            }
         }
         else
         {
            readNormalDay(calendar, day);
         }
      }
   }
1036002
public function getRelativeDayCount($end = null, $locale = null, $query = null, $cacheKey = null)
    {
        if (is_null($end))
        {
            $end = Carbon::today();
        }

        return $this->getCountInBetween($end, $end->copy()->endOfDay(), $locale, $query, $cacheKey);
    }
321724
@Override
	public double getDaycount(LocalDate startDate, LocalDate endDate) {
		if(startDate.isAfter(endDate)) {
			return -getDaycount(endDate,startDate);
		}

		int startDateDay 	= startDate.getDayOfMonth();
		int startDateMonth 	= startDate.getMonthValue();
		int startDateYear 	= startDate.getYear();

		int endDateDay 		= endDate.getDayOfMonth();
		int endDateMonth 	= endDate.getMonthValue();
		int endDateYear 	= endDate.getYear();


		// Check if we have last day of February
		boolean isStartDateLastDayOfFebruary = (startDateMonth == Month.FEBRUARY.getValue() && startDateDay == startDate.lengthOfMonth());
		boolean isEndDateLastDayOfFebruary = (endDateMonth == Month.FEBRUARY.getValue() && endDateDay == endDate.lengthOfMonth());

		// Last day of February and 31st of a month are both treated as "30".
		if(isStartDateLastDayOfFebruary || startDateDay == 31) {
			startDateDay = 30;
		}
		if((isEndDateLastDayOfFebruary && !isTreatEndDateAsTerminationDate) || endDateDay == 31) {
			endDateDay = 30;
		}

		return (endDateYear - startDateYear) * 360.0 + (endDateMonth - startDateMonth) * 30.0 + (endDateDay - Math.min(startDateDay, 30.0));
	}
386149
@Override
	public long getCount(long when){
		Long recWhen = when - (when % granularity);
		AtomicLong times = counters.get(recWhen);
		return times == null ? 0 : times.longValue(); 
	}
843003
public static LocalDate from(Calendar cal) {
        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH)+1;
        int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
        return new LocalDate(year, month, dayOfMonth);
    }
884617
static LocalDate toLocalDate(final Calendar self) {
        return LocalDate.of(self.get(Calendar.YEAR), toMonth(self), self.get(Calendar.DAY_OF_MONTH));
    }
1174423
private int getDaysToNextMatch(WeekDay weekDay) {

        for (WeekDay wd : m_weekDays) {
            if (wd.compareTo(weekDay) > 0) {
                return wd.toInt() - weekDay.toInt();
            }
        }
        return (m_weekDays.iterator().next().toInt() + (m_interval * I_CmsSerialDateValue.NUM_OF_WEEKDAYS))
            - weekDay.toInt();
    }
128931
public static int getDayOfWeek(@NotNull final Date date) {
		int result = getWithMondayFirst(date, Calendar.DAY_OF_WEEK);
		return result == 1 ? 7 : result - 1;
	}
1351796
public double getAccruedInterest(LocalDate date, AnalyticModel model) {
		int periodIndex=schedule.getPeriodIndex(date);
		Period period=schedule.getPeriod(periodIndex);
		DayCountConvention dcc= schedule.getDaycountconvention();
		double accruedInterest=getCouponPayment(periodIndex,model)*(dcc.getDaycountFraction(period.getPeriodStart(), date))/schedule.getPeriodLength(periodIndex);
		return accruedInterest;
	}
876576
public static Long getSunday() {
		cal.setTimeInMillis(System.currentTimeMillis());
		cal.add(Calendar.DATE, -dayOfWeek() + 7);
		return cal.getTimeInMillis();
	}
366469
public int getDay() {
    if (Date_Type.featOkTst && ((Date_Type)jcasType).casFeat_day == null)
      jcasType.jcas.throwFeatMissing("day", "de.julielab.jules.types.Date");
    return jcasType.ll_cas.ll_getIntValue(addr, ((Date_Type)jcasType).casFeatCode_day);}
583149
public static Integer getDay(Day day)
   {
      Integer result = null;
      if (day != null)
      {
         result = DAY_MAP.get(day);
      }
      return (result);
   }
433867
public LocalDate getEndAsLocalDate() {

        PlainDate date = this.getEndAsCalendarDate();
        return ((date == null) ? null : date.toTemporalAccessor());

    }
1297928
protected Calendar getLocalTimeAsCalendar(BigDecimal localTimeParam, Calendar date) {
        if (localTimeParam == null) {
            return null;
        }

        // Create a clone of the input calendar so we get locale/timezone information.
        Calendar resultTime = (Calendar) date.clone();

        BigDecimal localTime = localTimeParam;
        if (localTime.compareTo(BigDecimal.ZERO) == -1) {
            localTime = localTime.add(BigDecimal.valueOf(24.0D));
            resultTime.add(Calendar.HOUR_OF_DAY, -24);
        }
        String[] timeComponents = localTime.toPlainString().split("\\.");
        int hour = Integer.parseInt(timeComponents[0]);

        BigDecimal minutes = new BigDecimal("0." + timeComponents[1]);
        minutes = minutes.multiply(BigDecimal.valueOf(60)).setScale(0, RoundingMode.HALF_EVEN);
        if (minutes.intValue() == 60) {
            minutes = BigDecimal.ZERO;
            hour += 1;
        }
        if (hour == 24) {
            hour = 0;
        }

        // Set the local time
        resultTime.set(Calendar.HOUR_OF_DAY, hour);
        resultTime.set(Calendar.MINUTE, minutes.intValue());
        resultTime.set(Calendar.SECOND, 0);
        resultTime.set(Calendar.MILLISECOND, 0);
        resultTime.setTimeZone(date.getTimeZone());

        return resultTime;
    }
1157830
public static int getCalendarDay(final WeekDay weekday) {
        int calendarDay = -1;
        if (SU.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.SUNDAY;
        }
        else if (MO.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.MONDAY;
        }
        else if (TU.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.TUESDAY;
        }
        else if (WE.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.WEDNESDAY;
        }
        else if (TH.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.THURSDAY;
        }
        else if (FR.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.FRIDAY;
        }
        else if (SA.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.SATURDAY;
        }
        return calendarDay;
    }
80973
private LocalDate calculate3rdWednesday(final LocalDate original) {
        final LocalDate firstOfMonth = original.withDayOfMonth(1);
        LocalDate firstWed = firstOfMonth.withDayOfWeek(MONTHS_IN_QUARTER);
        if (firstWed.isBefore(firstOfMonth)) {
            firstWed = firstWed.plusWeeks(1);
        }
        return firstWed.plusWeeks(2);
    }