コード例 #1
0
ファイル: DayCount.java プロジェクト: David-Wales/OG-Commons
 /**
  * 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);
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
ファイル: DayCount.java プロジェクト: David-Wales/OG-Commons
 /**
  * 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);
 }