Class JPPFSchedule

java.lang.Object
org.jppf.scheduling.JPPFSchedule
All Implemented Interfaces:
Serializable

public class JPPFSchedule extends Object implements Serializable
Instances of this class contain data used to setup a schedule. This includes duration, date, date format.
Author:
Laurent Cohen
See Also:
  • Constructor Details

    • JPPFSchedule

      public JPPFSchedule(long duration)
      Initialize this schedule configuration with the specified duration.
      Parameters:
      duration - the duration in milliseconds. If the value is zero or less, then this schedule will expire immediately.
    • JPPFSchedule

      public JPPFSchedule(String date, String format)
      Initialize this schedule configuration with the specified fixed date annd date format.
      Parameters:
      date - the schedule date provided as a string. If the date is equal to or before the creation time of this schedule, then this schedule will expire immediately.
      format - the format in which the date is expressed (including locale and time zone information), as specified in the description of SimpleDateFormat.
    • JPPFSchedule

      public JPPFSchedule(ZonedDateTime zonedDateTime)
      Initialize this schedule configuration with the specified date.
      Parameters:
      zonedDateTime - the schedule date. If the date is equal to or before the creation time of this schedule, then this schedule will expire immediately.
    • JPPFSchedule

      public JPPFSchedule(Duration duration)
      Initialize this schedule configuration with the specified duration.
      Parameters:
      duration - the duration before this schedule expires or times out. If duaration resolves to a value of zero or less, then this schedule will expire immediately.
  • Method Details

    • getDuration

      public long getDuration()
      Get the duration for this configuration. The time at which the duration starts dependants on who is using it. For instance, for scheduling a job, it starts when the job is inserted into the job queue by the server.
      Returns:
      the timeout in milliseconds.
    • getDate

      public String getDate()
      Get the scheduled date for this configuration.
      Returns:
      the date in string format.
    • getFormat

      public String getFormat()
      Get the format of timeout date for this task.
      Returns:
      the date format as a string pattern.
    • getZonedDateTime

      public ZonedDateTime getZonedDateTime()
      Get the schedule date expressed as a ZonedDateTime instance.
      Returns:
      a ZonedDateTime if this schedule was constructed with a ZonedDateTime, otherwise null.
    • getDurationObject

      public Duration getDurationObject()
      Get the schedule duration expressed as a Duration instance.
      Returns:
      a Duration if this schedule was constructed with a a Duration, otherwise null.
    • toDate

      public Date toDate(long startDate) throws ParseException
      Deprecated.
      Convert this schedule to a Date object.
      Parameters:
      startDate - the starting date to use if the schedule is expressed as a duration.
      Returns:
      this schedule expressed as a Date.
      Throws:
      ParseException - if parsing using the simple date format fails.
    • toLong

      public long toLong(long startDate) throws ParseException
      Convert this schedule to a long value.
      Parameters:
      startDate - the starting date to use if the schedule is expressed as a duration.
      Returns:
      this schedule expressed as a long.
      Throws:
      ParseException - if parsing using the simple date format fails.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hasDate

      public boolean hasDate()
      Determine whether this schedule was initialized with a Date.
      Returns:
      true if a Date was specified when constructing this schedule, false otherwise.
    • hasDuration

      public boolean hasDuration()
      Determine whether this schedule was initialized with a duration.
      Returns:
      true if a long duration was specified when constructing this schedule, false otherwise.
    • hasZonedDateTime

      public boolean hasZonedDateTime()
      Determine whether this schedule was initialized with a ZonedDateTime.
      Returns:
      true if a ZonedDateTime was specified when constructing this schedule, false otherwise.
    • hasDurationObject

      public boolean hasDurationObject()
      Determine whether this schedule was initialized with a Duration.
      Returns:
      true if a Duration was specified when constructing this schedule, false otherwise.