java.lang.Object
com.flowingcode.vaadin.addons.recurrentschedulefield.api.TimeInterval
All Implemented Interfaces:
Serializable, Comparable<TimeInterval>

public class TimeInterval extends Object implements Serializable, Comparable<TimeInterval>
A class that represents a time interval (a time period defined by start and end points) according to ISO 8601.
Author:
Flowing Code
See Also:
  • Constructor Details

    • TimeInterval

      public TimeInterval(LocalDateTime start, LocalDateTime end)
      Creates a new TimeInterval with the specified start and end date-times.
      Parameters:
      start - the inclusive start date-time of the interval
      end - the exclusive end date-time of the interval
      Throws:
      IllegalArgumentException - if start is not before end
  • Method Details

    • getStartDate

      public LocalDateTime getStartDate()
      Returns the starting point of this interval.
    • getEndDate

      public LocalDateTime getEndDate()
      Returns the (exclusive) ending point of this interval.
    • includes

      public boolean includes(LocalDateTime date)
      Checks whether the given LocalDateTime falls within this interval.
      Returns:
      true if the argument is within this interval, false otherwise
    • isBefore

      public boolean isBefore(LocalDateTime date)
      Checks whether this interval falls before the specified LocalDateTime.
      Returns:
      true if this interval is before, false otherwise
    • isAfter

      public boolean isAfter(LocalDateTime date)
      Checks whether this interval falls after the specified LocalDateTime.
      Returns:
      true if this interval is after, false otherwise
    • getDuration

      public Duration getDuration()
      Gets the time duration (or time period) of this interval. The duration is calculated as the difference between the start and (exclusive) end times.
      Returns:
      a Duration representing the length of an interval
    • compareTo

      public int compareTo(TimeInterval o)
      Specified by:
      compareTo in interface Comparable<TimeInterval>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object