title: Get timestamp for start of day
body: <p>I am storing times/dates in a database using a unix timestamp.
  I want to then get all the instances on certain day so I therefore need to calculate the timestamp for the start of the day in order to query the database.</p>
  
  <p>I have done a similar thing in php by passing mktime the values for the day/month/year from a date object and setting hour and minute to zero.  There doesn't seem to be similar functions for this in java/android (the functions for getting the specific parts of date are deprecated)</p>
  
  <p>Can anyone give some guidance on this?  Thanks</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Ok so I realised this might work:</p>
  
  <pre><code>public static int startOfDay(Timestamp time) {
          Calendar cal = dateToCalendar(new Date(time.getTime()));
          cal.add(Calendar.HOUR_OF_DAY, -Calendar.HOUR_OF_DAY);
          cal.add(Calendar.MINUTE, -Calendar.MINUTE);
          cal.add(Calendar.SECOND, -Calendar.SECOND);
          Log.i("Time", cal.getTime().toString());        
          return (int) cal.getTimeInMillis()/1000;
  }
  </code></pre>
  
  <p>However when I ran this just now I got:</p>
  
  <p>Sat Dec 15 01:24:00 GMT 2012</p>
  
  <p>The seconds are right but the hour and minute are wrong??</p>