title: how to work with @scheduled annotation in spring
body: <p>I have to read time of a file(video) created and if the time of file is greater than 3 days i have to delete the files. For this i have used @scheduled annotation in spring. But when i run the application, that deletion code is not working. I have configured <code>xmlns:task="http://www.springframework.org/schema/task"
  http://www.springframework.org/schema/task
  http://www.springframework.org/schema/task/spring-task-3.0.xsd
  &lt;task:annotation-driven /&gt;</code> in spring xml file. It is showing schema reference 4:failed to read. So i have decided to use complete annotation. java version is 7 and spring version is 4.2.2. I have set cron expression at  4 PM and I ran application at 3.58 PM. Nothing executed. What am I missing. What is the best package(controller/service/secondary logic) to place this code. And I would also like to know How to implement DELETE method. This is my code for deleting videos</p>
  
  <pre><code>package com.test.logic;
  import java.io.File;
  import java.util.Date;
  import org.springframework.scheduling.annotation.EnableScheduling;
  import org.springframework.scheduling.annotation.Scheduled;
  import org.springframework.stereotype.Component;
  import com.sun.xml.internal.ws.developer.SchemaValidation;
  
  @Component
  @EnableScheduling
  public class VideoDelete {
      @Scheduled(cron="* 1-15 16 * * * *")
      public void deleteVideo(){
      System.out.println("========&gt; $$$$$$ scheduler method is executed $$$$$ &lt;==========");
          long presentTime=System.currentTimeMillis();
          Date presentDate=new Date(presentTime);
          File file=new File("E://videorecording1");
          File[] fileList=file.listFiles();
          for (File files : fileList){
              if (files.isFile()){
                  long filecreatedtime=files.lastModified();
                  Date fileDate=new Date(filecreatedtime);
                  long difference = presentDate.getTime() - fileDate.getTime();
                  long hoursDifference = difference / (60 * 60 * 1000);
                  if(hoursDifference &gt;= 72)
                      files.delete();
              }
          }
  }
  }
  </code></pre>