code: public Calendar getStartOfDay(long time) {
  
          Calendar cal = Calendar.getInstance();
          cal.setTimeInMillis(time);
          int year = cal.get(Calendar.YEAR);
          int month = cal.get(Calendar.MONTH);
          int day = cal.get(Calendar.DAY_OF_MONTH);
          Calendar result = Calendar.getInstance();
          result.set(Calendar.YEAR, year);
          result.set(Calendar.MONTH, month);
          result.set(Calendar.DAY_OF_MONTH, day);
          return result;
      }
docs: Returns a calendar object representing the start of the day in which a given time lies.<p>
  
  @param time a long representing a time
  
  @return a calendar object which represents the day in which the time lies