title: How do I compare event start times and end times with other events start time and end time
body: <p>I am making an android app that shows the Calendar day view, it looks like a list with colored blocks floating on top of it which represent event start time and end time. </p>
  
  <p>I was able to do everything correctly, however I wanted to sort events based on the same times or overlapping times or events which have start time or end time within the range of other event's start time and end time. </p>
  
  <p>Start time and end time are in Milliseconds.</p>
  
  <p>I store start times in startTimeList and end times in endTimeList and iterate through the list to compare the times.</p>
  
  <p>For the purpose of this I wrote this method which compares if the time is within the range of another event's start or end</p>
  
  <pre><code>public boolean isInRange(long timeToBeCompared,long startTime,long endTime){
    if(timeToBeCompared&gt;=startTime&amp;&amp;timeToBeCompared&lt;=endTime){
      return true;
      }
      return false;
    }
  </code></pre>
  
  <p>I put in first event's starttime or endtime through the above method and pass in second event's start and end time as second and third parameters and I check if its true and use a variable count to hold the count of similar start and end times. However my count value is wrong.</p>
  
  <p>Is there any other good approach?</p>