Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 1.56 KB

README.md

File metadata and controls

52 lines (40 loc) · 1.56 KB

Scheduler

javadoc build-status codecov

A clock-based ExecutorService using Java 8 Time. For when Quartz is just too heavy.

Scheduler is provided under the Apache License Version 2.0.

Examples

Using java.time

CalendarExecutorService executor = CalendarExecutorService.threadPool();

executor.schedule(
    () -> System.out.println("Remember me."),
    // Midnight (local time), 23 September 2017
    ZonedDateTime.of(2017, 09, 23, 13, 0, 0, ZoneId.systemDefault()).toInstant()
);

Using Cron

CalendarExecutorService executor = CalendarExecutorService.threadPool();

CronParser parser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));

executor.schedule(
    () -> System.out.println("Ding dong."),
    // Every hour, on the hour, Monday to Friday, 9am to 5pm
    parser.parse("0 0 9-17 * * * 1-5")
);

Getting Started

Scheduler is available in Maven Central, using the following coordinates:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>au.id.ajlane.scheduler</groupId>
      <artifactId>scheduler</artifactId>
      <version>0.0.3</version>
    </dependency>
  </dependencies>
  ...
</project>