title: Java overlapping date
body: <p>I have this programming exercise which looks for overlapping date ranges.</p>
  
  <p>So far this is what I've done:</p>
  
  <pre><code>  private static final SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd, yyyy");
  private static final Date invalidDate = new Date(0);
  
  private static final Date fromString( String spec ) {
      try {
          return dateFormat.parse( spec );
      } catch( ParseException dfe ) {
          return invalidDate;
      }
  }
  
  public static void main(String[] args) {
  
      Date [] randomDates = {
              fromString("Aug 28, 2014"), 
              fromString("Sep 1, 2014"), 
              fromString("Aug 30, 2014"), 
              fromString("Sep 3, 2014"), 
              fromString("Sep 5, 2014"),
              fromString("Sep 7, 2014")
          };
  
      for( Date date: randomDates ) {
          print( date );
      }
  
  }
  
  private static final void print( Date date ) {
      if( date == invalidDate ) {
          System.out.println("Invalid date");
      } else {
          System.out.println( dateFormat.format( date ) );
      }
  }
  </code></pre>
  
  <p>But I can't seem to figure out the overlapping of dates. Or I don't still get how to find the overlapping dates. Any ideas? Your help will be truly appreciated. </p>