`
TreasureNow
  • 浏览: 19851 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

java run at specific time

    博客分类:
  • java
 
阅读更多
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class ReportGenerator extends TimerTask {

  public void run() {
    System.out.println("Generating report");
    //TODO generate report
  }

}

class MainApplication {

  public static void main(String[] args) {
    Timer timer  new Timer();
    Calendar date = Calendar.getInstance();
    date.set(
      Calendar.DAY_OF_WEEK,
      Calendar.SUNDAY
    );
    date.set(Calendar.HOUR, 0);
    date.set(Calendar.MINUTE, 0);
    date.set(Calendar.SECOND, 0);
    date.set(Calendar.MILLISECOND, 0);
    // Schedule to run every Sunday in midnight
    timer.schedule(
      new ReportGenerator(),
      date.getTime(),
      1000 * 60 * 60 * 24 * 7
    );
  }
}

 

分享到:
评论

相关推荐

    JAVA-Based Agent Platform Evaluation

    development tools (platforms) with respect to the specific requirements of agent-based manufacturing control solutions. We discuss the use of agents, as high-level decision-making entities, in ...

    Java APIs, Extensions and Libraries-Apress(2018).pdf

    The Applet API in JDK9 has been deprecated and all modern browsers either have discontinued or will discontinue the support for the Java plug-in, which is needed to run applets. I consider the Applet...

    Java邮件开发Fundamentals of the JavaMail API

    You will also run across NNTP and some others. Understanding the basics of all the protocols will help you understand how to use the JavaMail API. While the API is designed to be protocol agnostic, ...

    JSP Simple Examples

    This standard action is used to include a file at run time. This standard action is evaluated at the run time. Snoop in JSP It mostly contains the request information, ServletContext initialization...

    Clojure High Performance Programming(PACKT,2ed,2015)

    At the end of the book, you will learn to run a performance profiler, identify bottlenecks, tune performance, and refactor code to get a better performance. What You Will Learn Identify performance...

    外文翻译 stus MVC

    If you where slick, you would place the configuration information into a file and load the file at run time. Function pointer arrays were the good old days of structured programming in C. Life is ...

    Apache Geronimo 2.1_ Quick Reference.pdf

    Setting transaction timeout 145 Transaction isolation levels 145 Transactions in web applications 146 Summary 148 Chapter 6: Security 149 Overview of security standards 149 Java Authentication ...

    用于大规模的生产部署Squbs.zip

    For instance, in cases where we have mixed cloud environments such as private and public cloud needing different operational tools, the same codebase will work with ...-time addition of environment...

    Software Development, Design and Coding-2nd Edition-Apress(2017).pdf

    As I’ve said already, we’ll be spending a lot of time examining how to design and implement programs that solve specific problems. By the way, there’s at least one other person (besides me) who ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Other C++ Features Reference Arguments Function Overloading Default Arguments Variable-Length Arrays and alloca() Friends Exceptions Run-Time Type Information (RTTI) Casting Streams Preincrement and ...

    UE(官方下载)

    Parsing XML can be a time-consuming task, especially when large amounts of data are involved. As of v15.10, UltraEdit provides you with a the XML Window for the purpose of parsing ...

    tomcat-7_API_帮助文档

    Java Development Kit (JDK) to run Tomcat, but a Java Runtime Environment (JRE) is sufficient. The Eclipse JDT Java compiler is bundled with the binary Tomcat distributions. Tomcat can also be ...

    Professional Assembly Language

    as C, C++, or even Java. This book does not spend much time teaching basic programming principles. It assumes that you are already familiar with the basics of computer programming, and are ...

    tomcat-8_API

    Tomcat 8.0 is designed to run on Java SE 7 and later. ============== API Stability: ============== The public interfaces for the following classes are fixed and will not be changed at all during ...

    ap6212a0_a33_sc3817r_服务器验证通过_bt已经通了_wifi需要修改配置_需要再次验证_20170626_1549.7z

    persist.sys.timezone=Asia/Shanghai \ persist.sys.language=zh \ persist.sys.country=CN PRODUCT_PACKAGES += Bluetooth #PRODUCT_PROPERTY_OVERRIDES += \ # ro.product.8723b_bt.used=true #GPS Feature ...

    spring-boot-reference.pdf

    runApplication 47.3.2. Extensions 47.4. Dependency management 47.5. @ConfigurationProperties 47.6. Testing 47.7. Resources 47.7.1. Further reading 47.7.2. Examples 48. What to Read Next V. Spring ...

    ap6212a0_a33_sc3817r_神舟验证版本_借用nvram_ap6210这个配置文件_20170626_1834没有外层目录.7z

    persist.sys.timezone=Asia/Shanghai \ persist.sys.language=zh \ persist.sys.country=CN PRODUCT_PACKAGES += Bluetooth #PRODUCT_PROPERTY_OVERRIDES += \ # ro.product.8723b_bt.used=true #GPS Feature ...

    Visual C++ 编程资源大全(英文源码 控件)

    10.zip Owner Drawn Font Selection ComboBox 自画的字体选择ComboBox(5KB)<END><br>11,add.zip This sample was developed on stage at the Washington Software Association's WinSIG meeting on the ...

    python3.6.5参考手册 chm

    PEP 495: Local Time Disambiguation PEP 529: Change Windows filesystem encoding to UTF-8 PEP 528: Change Windows console encoding to UTF-8 PEP 520: Preserving Class Attribute Definition Order PEP ...

    hm1375_parrotv1.1验证通过_20170824_1528.7z

    See the License for the specific language governing permissions and limitations under the License. --> <!DOCTYPE MediaSettings [ <!ELEMENT MediaSettings (CamcorderProfiles, EncoderOutputFileFormat+...

Global site tag (gtag.js) - Google Analytics