code: private static long getDateForHour(long dt, TimeZone tz, int hour, int dayoffset)
      {
          Calendar c = getCalendar(tz);
          c.setTimeInMillis(dt);
          int dd = c.get(Calendar.DAY_OF_MONTH);
          int mm = c.get(Calendar.MONTH);
          int yy = c.get(Calendar.YEAR);
          c.set(yy, mm, dd, hour, 0, 0);
          c.set(Calendar.MILLISECOND, 0);
          if(dayoffset != 0)
              c.add(Calendar.DAY_OF_MONTH, dayoffset);
          return c.getTimeInMillis();
      }
docs: Returns the date for the given hour.
  @param dt The date to be checked
  @param tz The timezone associated with the date
  @param hour The hour to be checked
  @param dayoffset The day of the month to offset
  @return The date for the given hour