class YieldAndDiscountCurveUtils {

  public static double zeroCouponRate(final YieldAndDiscountCurve curve, final ZonedDateTime curveDate, final ZonedDateTime payDate, final DayCount dc, final int paymentPerYear) {
    ArgumentChecker.notNull(curve, "curve");
    ArgumentChecker.notNull(curveDate, "curveDate");
    ArgumentChecker.notNull(payDate, "payDate");
    ArgumentChecker.notNull(dc, "dayCount");
    final double timeCurve = TimeCalculator.getTimeBetween(curveDate, payDate);
    final double df = curve.getDiscountFactor(timeCurve);
    final double timeDc = dc.getDayCountFraction(curveDate, payDate);
    if (paymentPerYear > 0) {
      final double rate = paymentPerYear * (Math.pow(df, -1.0 / (paymentPerYear * timeDc)) - 1.0);
      return rate;
    }
    final double rate = -Math.log(df) / timeDc;
    return rate;
  }

}