`
TreasureNow
  • 浏览: 20768 次
  • 性别: 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 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...

    groovy_in_action_draft_ch_01.pdf

    At the same time, it has corporate backing, which ensures stability and support. Companies such as Pivotal (now part of VMware) have been instrumental in supporting Groovy, contributing to its ...

    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 ...

    AkkaScala.pdf

    4. **Platform Independence:** Akka is built on the JVM, which means it can run on any platform that supports Java. This makes it easy to deploy Akka-based applications across different environments ...

    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 ...

    Efficient MIDP Programming

    - **Sampling**: Collecting data about the application’s behavior at regular intervals. ###### 2.1.2 Graphics Operations Graphics operations are often a significant source of performance issues in ...

    Android Studio Essentials

    1. **Instant Run**: Instant Run (now called Apply Changes) allows you to apply code and resource changes to your running app without restarting the app or the emulator. This feature significantly ...

    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 ...

    Packt.Mastering.Csharp.and.NET.Programming

    - **Common Intermediate Language (CIL)**: The intermediate code generated by compilers for .NET languages, which is then compiled to machine code at runtime by the Just-In-Time (JIT) compiler. ...

    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 ...

    impala-2.8

    - **Java Dependencies**: Java runtime environment is required. - **Networking Configuration**: Proper network configuration to ensure connectivity between Impala daemons and other services. - **...

Global site tag (gtag.js) - Google Analytics