title: How to remove Hour, Minute, and Second from Epoch timestamp
body: <p>I need to write a function that accepts a <code>java.util.Date</code> and removes the hours, minutes, and milliseconds from it <strong>USING JUST MATH (no Date formatters, no Calendar objects, etc.)</strong>:</p>
  
  <pre><code>private Date getJustDateFrom(Date d) {
      //remove hours, minutes, and seconds, then return the date
  }
  </code></pre>
  
  <p>The purpose of this method is to get the date from a millisecond value, without the time.</p>
  
  <p>Here's what I have so far: </p>
  
  <pre><code>private Date getJustDateFrom(Date d) {
      long milliseconds = d.getTime();
      return new Date(milliseconds - (milliseconds%(1000*60*60)));
  }
  </code></pre>
  
  <p>The problem is, this only removes minutes and seconds. I don't know how to remove hours.</p>
  
  <p>If I do <code>milliseconds - (milliseconds%(1000*60*60*23))</code>, then it goes back to 23:00 hrs on the previous day.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here's an alternative solution:</p>
  
  <pre><code>public static Date getJustDateFrom(Date d) {
      Calendar c = Calendar.getInstance();
      c.setTime(d);
      c.set(Calendar.HOUR_OF_DAY, 0);
      c.set(Calendar.MINUTE, 0);
      return c.getTime();
  }
  </code></pre>
  
  <p>Will this solution be affected by time zone differences between the client/server sides of my app?</p>