title: Sorting list of objects on datetime (cannot resolve method 'compareTo')
body: <p>I'm trying to sort an array of objects according to the DateTime of the objects. I've used the following example to create my solution:</p>
  
  <p><a href="https://stackoverflow.com/questions/5927109/sort-objects-in-arraylist-by-date">Sort objects in ArrayList by date?</a></p>
  
  <p>The method I use looks like this:</p>
  
  <pre><code>        List&lt;SomeEvent&gt; myEvents = new ArrayList&lt;&gt;();
  //...
  //left out the part where the List is filled with Objects
  //...
          Collections.sort(myEvents, new Comparator&lt;SomeEvent&gt;() {
              public int compare(SomeEvent se1, SomeEvent se2) {
                  return se1.getStartTime().compareTo(se2.getStartTime());
              }
          });
  </code></pre>
  
  <p>I get the error message "Cannot resolve method 'compareTo(com.google.api.client.util.DateTime)'</p>
  
  <p>Any pointers as to what I'm missing? </p>
  
  <p>Edit:
  My class SomeEvent now implements Comparable as suggested:</p>
  
  <pre><code>public class SomeEvent extends SomeTask implements Comparable&lt;SomeEvent&gt;
  { 
  private DateTime startTime; 
  
  private DateTime endTime;
  
  
       public DateTime getStartTime() {
           return startTime;
       }
  
       public DateTime getEndTime() {
           return endTime;
       }
  
   }
  </code></pre>
  
  <p>Now, however, I get the hint that I need to either declare my class as abstract (which is not possible in the context it is used) or implement the abstract method 'compareTo(T)' in 'Comparable'.</p>
  
  <p>How can I implement the abstract method?</p>