Example #1
0
 /**
  * Gets the relative year fraction between the specified dates.
  *
  * <p>Given two dates, this method returns the fraction of a year between these dates according to
  * the convention. The result of this method will be negative if the first date is after the
  * second date. The result is calculated using {@link #yearFraction(LocalDate, LocalDate,
  * ScheduleInfo)}.
  *
  * @param firstDate the first date
  * @param secondDate the second date, which may be before the first date
  * @param scheduleInfo the schedule information
  * @return the year fraction, may be negative
  * @throws UnsupportedOperationException if the year fraction cannot be obtained
  */
 public default double relativeYearFraction(
     LocalDate firstDate, LocalDate secondDate, ScheduleInfo scheduleInfo) {
   ArgChecker.notNull(firstDate, "firstDate");
   ArgChecker.notNull(secondDate, "secondDate");
   ArgChecker.notNull(scheduleInfo, "scheduleInfo");
   if (secondDate.isBefore(firstDate)) {
     return -yearFraction(secondDate, firstDate, scheduleInfo);
   }
   return yearFraction(firstDate, secondDate, scheduleInfo);
 }
 /**
  * Adjusts the date as necessary if it is not a business day.
  *
  * <p>If the date is a business day it will be returned unaltered. If the date is not a business
  * day, the convention will be applied.
  *
  * @param date the date to adjust
  * @return the adjusted temporal
  */
 @Override
 public LocalDate adjust(LocalDate date) {
   ArgChecker.notNull(date, "date");
   return convention.adjust(date, calendar);
 }
Example #3
0
 /**
  * Obtains a {@code DayCount} from a unique name.
  *
  * @param uniqueName the unique name
  * @return the day count
  * @throws IllegalArgumentException if the name is not known
  */
 @FromString
 public static DayCount of(String uniqueName) {
   ArgChecker.notNull(uniqueName, "uniqueName");
   return extendedEnum().lookup(uniqueName);
 }