title: How to retrieve data from database based on date in java?
body: <p>Here is what I have tried</p>
  
  <p>Controller:</p>
  
  <pre><code>public void lovForFincurrency() {
  
      LOG.info("\n\n\nINSIDE \n CLASS == LovController \n METHOD == lovForFincurrency(); ");
      try {
  
          apexManagerService = ServiceManagerFactory.getServiceManager(getServletContext());
          MmsBean mmsBean = (MmsBean) getControllerObject(ApexManagedBean.MMSBEAN.getName(), MmsBean.class);
          PmBean pmBean = (PmBean) getControllerObject(ApexManagedBean.PMBEAN.getName(), PmBean.class);
          final FinCurrencyService finsurrencyservice = apexManagerService.getFinCurrencyService();
  
          DateFormat dateFormat = new SimpleDateFormat("MM/DD/YYYY HH:mm:ss");
          Date date = new Date();
  
          List&lt;Fincurrency&gt; fincurrencies = finsurrencyservice.readcurrencies("Y", date);
  
          List&lt;Admlov&gt; admlovs = new ArrayList&lt;Admlov&gt;();
  
          for (Fincurrency fincurrency : fincurrencies) {
              Admlov admlov = new Admlov();
  
              admlov.setId(fincurrency.getCurrency());
              admlov.setCode(fincurrency.getSymbol());
              admlov.setDescr(fincurrency.getDescr());
              admlovs.add(admlov);
  
          }
  
          if (admlovs != null) {
              mmsBean.setAdmlovs(admlovs);
          }
  
      } catch (Exception ex) {
          LOG.error(ex.getMessage(), ex);
          addMessageToFacesContext(ERROR_DELETE);
      }
      LOG.info("EXITING THIS METHOD \n\n\n");
  
  }
  </code></pre>
  
  <p>Here is my Repository:</p>
  
  <pre><code>public interface FinCurrencyRepo extends JpaRepository&lt;Fincurrency, String&gt; {
  
      List&lt;Fincurrency&gt; findByEffectivefromAfterAndEffectivetoBeforeAndEnabled(Date sysdate, Date sysdate1,
              String enabled);
  }
  </code></pre>
  
  <p>Here is my serviceimplementation:</p>
  
  <pre><code>@Override
  public List&lt;Fincurrency&gt; readcurrencies(String enabled, Date sysdate) {
      return fincurrencyRepo.findByEffectivefromAfterAndEffectivetoBeforeAndEnabled(sysdate, sysdate, enabled);
  }
  </code></pre>
  
  <p>Here is my Fincurrency Entity: I want to show symbol and currency in datatable of this year and after this year but not before this year. Kindly help me in this issue.</p>
  
  <pre><code>public class Fincurrency implements Serializable {
  
      @Id
      private String currency;
  
      //@Temporal(TemporalType.DATE)
      private Date effectivefrom;
  
      //@Temporal(TemporalType.DATE)
      private Date effectiveto;
  
      private String enabled;
  
      private String symbol;
  
      @Column(name="\"TYPE\"")
      private String type;
  
      public Fincurrency() {
      }
  
      public String getCurrency() {
          return this.currency;
      }
  
      public void setCurrency(String currency) {
          this.currency = currency;
      }
  
      public BigDecimal getAfterdecimal() {
          return this.afterdecimal;
      }
  
      public void setAfterdecimal(BigDecimal afterdecimal) {
          this.afterdecimal = afterdecimal;
      }
  
      public Date getEffectivefrom() {
          return this.effectivefrom;
      }
  
      public void setEffectivefrom(Date effectivefrom) {
          this.effectivefrom = effectivefrom;
      }
  
      public Date getEffectiveto() {
          return this.effectiveto;
      }
  
      public void setEffectiveto(Date effectiveto) {
          this.effectiveto = effectiveto;
      }
  
      public String getEnabled() {
          return this.enabled;
      }
  
      public void setEnabled(String enabled) {
          this.enabled = enabled;
      }
  
      public String getSymbol() {
          return this.symbol;
      }
  
      public void setSymbol(String symbol) {
          this.symbol = symbol;
      }
  
  }
  </code></pre>