code: protected Query createDateRangeFilter(String fieldName, long startTime, long endTime) {
  
          Query filter = null;
          if ((startTime != Long.MIN_VALUE) || (endTime != Long.MAX_VALUE)) {
              // a date range has been set for this document search
              if (startTime == Long.MIN_VALUE) {
                  // default start will always be "yyyy1231" in order to reduce term size
                  Calendar cal = Calendar.getInstance(OpenCms.getLocaleManager().getTimeZone());
                  cal.setTimeInMillis(endTime);
                  cal.set(cal.get(Calendar.YEAR) - MAX_YEAR_RANGE, 11, 31, 0, 0, 0);
                  startTime = cal.getTimeInMillis();
              } else if (endTime == Long.MAX_VALUE) {
                  // default end will always be "yyyy0101" in order to reduce term size
                  Calendar cal = Calendar.getInstance(OpenCms.getLocaleManager().getTimeZone());
                  cal.setTimeInMillis(startTime);
                  cal.set(cal.get(Calendar.YEAR) + MAX_YEAR_RANGE, 0, 1, 0, 0, 0);
                  endTime = cal.getTimeInMillis();
              }
  
              // get the list of all possible date range options
              List<String> dateRange = getDateRangeSpan(startTime, endTime);
              List<Term> terms = new ArrayList<Term>();
              for (String range : dateRange) {
                  terms.add(new Term(fieldName, range));
              }
              // create the filter for the date
              BooleanQuery.Builder build = new BooleanQuery.Builder();
              terms.forEach(term -> build.add(new TermQuery(term), Occur.SHOULD));
              filter = build.build();
          }
          return filter;
      }
docs: Creates an optimized date range filter for the date of last modification or creation.<p>
  
  If the start date is equal to {@link Long#MIN_VALUE} and the end date is equal to {@link Long#MAX_VALUE}
  than <code>null</code> is returned.<p>
  
  @param fieldName the name of the field to search
  @param startTime start time of the range to search in
  @param endTime end time of the range to search in
  
  @return an optimized date range filter for the date of last modification or creation