Class Time

  • All Implemented Interfaces:
    Serializable

    @PublicEvolving
    public final class Time
    extends Object
    implements Serializable
    The definition of a time interval. Similar to a simpler version of Duration.

    Note: This class will fully replace org.apache.flink.streaming.api.windowing.time.Time in Flink 2.0

    See Also:
    Serialized Form
    • Method Detail

      • getUnit

        public TimeUnit getUnit()
        Gets the time unit for this policy's time interval.
        Returns:
        The time unit for this policy's time interval.
      • getSize

        public long getSize()
        Gets the length of this policy's time interval.
        Returns:
        The length of this policy's time interval.
      • toMilliseconds

        public long toMilliseconds()
        Converts the time interval to milliseconds.
        Returns:
        The time interval in milliseconds.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • of

        public static Time of​(long size,
                              TimeUnit unit)
        Creates a new Time of the given duration and TimeUnit.
        Parameters:
        size - The duration of time.
        unit - The unit of time of the duration, for example TimeUnit.SECONDS.
        Returns:
        The time policy.
      • milliseconds

        public static Time milliseconds​(long milliseconds)
        Creates a new Time that represents the given number of milliseconds.
      • seconds

        public static Time seconds​(long seconds)
        Creates a new Time that represents the given number of seconds.
      • minutes

        public static Time minutes​(long minutes)
        Creates a new Time that represents the given number of minutes.
      • hours

        public static Time hours​(long hours)
        Creates a new Time that represents the given number of hours.
      • days

        public static Time days​(long days)
        Creates a new Time that represents the given number of days.
      • fromDuration

        public static Time fromDuration​(java.time.Duration duration)
        Creates a new Time that represents the number of milliseconds in the given duration.