title: Joda LocalDate compare if equal or before and after
body: <p>I want to compare joda LocalDate objects and check/compare if the date is between two dates.</p>
  <p>Example:</p>
  <pre><code>LocalDate date = new LocalDate(2019, 2, 2);
  LocalDate end = new LocalDate();
  LocalDate start = end.minusYears(1);
  </code></pre>
  <p>Now, I want to check if <code>date</code> is between <code>start</code> and <code>end</code>.
  Also, I want it to work like <code>gte</code> and <code>lte</code>... is before or equal and is after or equal.</p>
  <p>I can only find <code>isBefore</code>, <code>isAfter</code>, <code>isEqual</code>... but I cannot find <code>isBeforeOrEqual</code> and <code>isAfterOrEqual</code>.</p>
  <p>Is there any utility that can work with joda LocalDate? Is there any efficient way to solve this?</p>
  <p>I am thinking to check <code>isBefore</code> then <code>isEqual</code>, same with <code>isAfter</code> then <code>isEqual</code>... but I think it is quite long or inefficient.</p>
  <pre><code>private boolean isBeforeOrEqual(LocalDate date, LocalDate compareToDate) {
      if (date == null || compareToDate == null) {
          return false;
      }
      return compareToDate.isBefore(date) || compareToDate.isEqual(date);
  }
  
  private boolean isAfterOrEqual(LocalDate date, LocalDate compareToDate) {
      if (date == null || compareToDate == null) {
          return false;
      }
      return compareToDate.isAfter(date) || compareToDate.isEqual(date);
  }
  </code></pre>
  <p>After Alex's comment below, I rewrite the methods <code>isBeforeOrEqual</code> and <code>isAfterOrEqual</code> and it is a lot shorter. Thanks a lot Alex.</p>
  <pre><code>private boolean isBeforeOrEqual(LocalDate date, LocalDate compareToDate) {
      if (date == null || compareToDate == null) {
          return false;
      }
      return !compareToDate.isAfter(date);
  }
  
  private boolean isAfterOrEqual(LocalDate date, LocalDate compareToDate) {
      if (date == null || compareToDate == null) {
          return false;
      }
      return !compareToDate.isBefore(date);
  }
  </code></pre>
  <p>Thanks!</p>