# Buscar una fecha y hora en un rango

Busca si una fecha y hora esta en el rango

![](/files/-Lc1X7IrWclsfl611BU3)

En el Sevices

Busca los documentos de ese usuario e inicia el filtro.

```java
  // <editor-fold defaultstate="collapsed" desc="coincidenciaEnRango(Solicitud solicitud)">

    /**
     * coincide en el rango con la orden que se devuelve o un entity si no coincide
     * @param solicitud
     * @return 
     */

  public  Optional<Solicitud> coincidenciaEnRango(Solicitud solicitud) {
        Integer idsolicitud=0;
        try {

              List<Solicitud> list = repository.findBy(new Document("usuario.username", solicitud.getUsuario().getUsername()), new Document("idsolicitud", -1));
            if (!list.isEmpty()) {
                for (Solicitud s : list) {
                    if (JsfUtil.dateBetween(solicitud.getFechahorapartida(), s.getFechahorapartida(), s.getFechahoraregreso())
                            || JsfUtil.dateBetween(solicitud.getFechahoraregreso(), s.getFechahorapartida(), s.getFechahoraregreso())) {

// coincide en el rango de fecha y hora con la solicitud s
                        return Optional.of(s);
                    }
                }
            }
        } catch (Exception e) {
              JsfUtil.errorMessage("coincidenciaEnRango() " + e.getLocalizedMessage());
        }
        return Optional.empty();
    }

    // </editor-fold>
```

En el Controller

```java
Optional<Solicitud> optionalRango = solicitudServices.coincidenciaEnRango(solicitud);
if(optionalRango.isPresent()){
       JsfUtil.warningDialog(rf.getAppMessage("warning.view"),rf.getMessage("warning.solicitudnumero")+ " " + optionalRango.get().getIdsolicitud().toString() + "  " + rf.getMessage("warning.solicitudfechahoraenrango"));
                        return ""; 
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/trucosjakartaee/overview/rangos-de-fechas/buscar-una-fecha-y-hora-en-un-rango.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
