@Override
  public long periodUntil(DateTime endDateTime, PeriodUnit unit) {

    if (endDateTime instanceof LocalDate == false) {
      throw new DateTimeException("Unable to calculate period between objects of two different types");
    }
    LocalDate end = (LocalDate) endDateTime;
    if (unit instanceof ChronoUnit) {
      switch ((ChronoUnit) unit) {
        case DAYS:
          return daysUntil(end);
        case WEEKS:
          return daysUntil(end) / 7;
        case MONTHS:
          return monthsUntil(end);
        case QUARTER_YEARS:
          return monthsUntil(end) / 3;
        case HALF_YEARS:
          return monthsUntil(end) / 6;
        case YEARS:
          return monthsUntil(end) / 12;
        case DECADES:
          return monthsUntil(end) / 120;
        case CENTURIES:
          return monthsUntil(end) / 1200;
        case MILLENNIA:
          return monthsUntil(end) / 12000;
        case ERAS:
          return end.getLong(ERA) - getLong(ERA);
      }
      throw new DateTimeException("Unsupported unit: " + unit.getName());
    }
    return unit.between(this, endDateTime).getAmount();
  }