title: How to remove milliseconds, seconds, minutes and hours from Date
body: <p>I ran into a problem where I wanted to compare two dates. However, I only wanted to compare Year, Month and Day. And this is what I can up with: </p>
  
  <pre><code> private Date trim(Date date) {
  
          Calendar calendar = Calendar.getInstance();
          calendar.setTime(date);
          calendar.set(Calendar.MILLISECOND, 0);
          calendar.set(Calendar.SECOND, 0);
          calendar.set(Calendar.MINUTE, 0);
          calendar.set(Calendar.HOUR, 0);
          return calendar.getTime();
      }
  </code></pre>
  
  <p>I user this function to trim all units but days, months and years. </p>
  
  <p>Now, the question is what do you think about it? 
  Do you know any other way to do so? </p>
  
  <p>Thanks</p>