code: private Date adjustForWholeDay(Date date, boolean isEnd) {
  
          Calendar result = new GregorianCalendar();
          result.setTime(date);
          result.set(Calendar.HOUR_OF_DAY, 0);
          result.set(Calendar.MINUTE, 0);
          result.set(Calendar.SECOND, 0);
          result.set(Calendar.MILLISECOND, 0);
          if (isEnd) {
              result.add(Calendar.DATE, 1);
          }
  
          return result.getTime();
      }
docs: Adjust the date according to the whole day options.
  
  @param date the date to adjust.
  @param isEnd flag, indicating if the date is the end of the event (in contrast to the beginning)
  
  @return the adjusted date, which will be exactly the beginning or the end of the provide date's day.