title: Schedule a function in spring boot with @Scheduled annotation
body: <p>I would like to execute the following method at the date and time speified on my Angular form
  -Here is the input:</p>
  <pre><code>&lt;input required [(ngModel)]=&quot;emailNotification.sendingDate&quot; class=&quot;form-control&quot; type=&quot;datetime-local&quot; name=&quot;sendingDate&quot; id=&quot;time&quot;&gt;
  
  </code></pre>
  <p>The sending emails method(from the controller)</p>
  <pre><code>@PostMapping(value=&quot;/getdetails&quot;)
      public @ResponseBody void sendMail(@RequestBody EmailNotification details) throws Exception {
          try {
              JavaMailSenderImpl jms = (JavaMailSenderImpl) sender;
              MimeMessage message = jms.createMimeMessage();
              MimeMessageHelper helper = new MimeMessageHelper(message, MimeMessageHelper.MULTIPART_MODE_MIXED_RELATED, StandardCharsets.UTF_8.name());
  
              
              helper.setFrom(&quot;smsender4@gmail.com&quot;);
              List&lt;String&gt; recipients = fileRepo.findWantedEmails(details.getDaysNum());
              String[] to = recipients.stream().toArray(String[]::new);
              helper.setTo(to);
              helper.setText(details.getMessage(),true);
              helper.setSubject(&quot;Test Mail&quot;);
              details.setRecipients(to);
              sender.send(message);
              enr.save(new EmailNotification(details.getId(), &quot;Test mail&quot;, details.getMessage(), details.getDaysNum(), details.getRecipients(), details.getSendingDate()));
          } catch (MessagingException e) {
              throw new RuntimeException(&quot;fail to send emails: &quot; + e.getMessage());
          }
         
  </code></pre>
  <p>EmailNotification.class</p>
  <pre><code>public class EmailNotification {
      
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private long id;
      private String subject;
      private String message;
      private int daysNum;
      private String[] recipients;
      /*
       * @Temporal(TemporalType.TIMESTAMP)
       */ 
      //&quot;yyyy-MM-dd'T'HH:mm:ss.SSSX&quot;
      @Column(name = &quot;sending_date&quot;)
      @Basic(fetch = FetchType.EAGER)
      private LocalDateTime sendingDate;
  
      public EmailNotification(long id, String subject,String message, int daysNum, String[] recipients, LocalDateTime sendingDate) {
          super();
          this.sendingDate = sendingDate;
          this.daysNum = daysNum;
          this.id = id;
          this.message = message;
          this.subject = subject;
      }
      
      
  </code></pre>
  <p>I don't know how to proceed, Iùll be so gratefull  if someone helped</p>