title: How do I replace the deprecated method Date.setHours(int)?
body: <p>I have some deprecated <code>Date</code> methods in my Java code and I would appreciate if someone can guide me here please. I have a private Date variable:</p>
  
  <pre><code>private Date startime;
  private Date endTime;
  </code></pre>
  
  <p>and in my method I have declared:</p>
  
  <pre><code>Calendar calender = Calendar.getInstance();
  this.startTime = calender.getTime();
  this.startTime.setHours(0); // ----&gt; is depreacted
  
  this.endTime.setHours(startTime.getHours()); // --&gt;deprecated line as well
  </code></pre>
  
  <p>Other methods such as <code>setMinutes()</code> and <code>getMinutes()</code> are also deprecated.</p>
  
  <p>I know that I have to use <code>Calendar.set(Calendar.HOUR_OF_DAY, hour)</code>. How can use the new code here? all the setHours, getMinutes, etc are all over-lined. </p>
  
  <pre><code>        if (query.getCount() &gt; 0 &amp;&amp; query.moveToFirst()) {
            Calendar calender = Calendar.getInstance();
            this.startTime = calender.getTime();
            this.startTime.setHours(0);
            this.startTime.setMinutes(query.getInt("startTimeOfDayMins"));
  
            this.daysOfWeek = (query.getString("daysOfWeek")).toLowerCase();
  
            this.endTime = calender.getTime();
            this.endTime.setHours(startTime.getHours());
            this.endTime.setMinutes(startTime.getMinutes() + query.getInt("durationMins"));
  
          this.context = null;
      }
  </code></pre>