Class Activity.Timestamps

  • Enclosing interface:
    Activity

    public static class Activity.Timestamps
    extends java.lang.Object
    Represents the start and end timestamps for a running match
    • Constructor Summary

      Constructors 
      Constructor Description
      Timestamps​(long start, long end)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      long getElapsedTime​(java.time.temporal.TemporalUnit unit)
      Calculates the elapsed time from getStartTime() to now in terms of the specified unit.
      long getEnd()
      Epoch second timestamp of match end, or 0 of unset.
      java.time.Instant getEndTime()
      Shortcut for Instant.ofEpochSecond(start)
      long getRemainingTime​(java.time.temporal.TemporalUnit unit)
      Calculates the amount of time until getEndTime() in terms of the specified unit.
      long getStart()
      Epoch second timestamp of match start, or 0 of unset.
      java.time.Instant getStartTime()
      Shortcut for Instant.ofEpochSecond(start)
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Timestamps

        public Timestamps​(long start,
                          long end)
    • Method Detail

      • getStart

        public long getStart()
        Epoch second timestamp of match start, or 0 of unset.
        Returns:
        Epoch second timestamp of match start, or 0 of unset.
      • getStartTime

        @Nullable
        public java.time.Instant getStartTime()
        Shortcut for Instant.ofEpochSecond(start)
        Returns:
        Instant of match start, or null if unset
      • getEnd

        public long getEnd()
        Epoch second timestamp of match end, or 0 of unset.
        Returns:
        Epoch second timestamp of match end, or 0 of unset.
      • getEndTime

        @Nullable
        public java.time.Instant getEndTime()
        Shortcut for Instant.ofEpochSecond(start)
        Returns:
        Instant of match start, or null if unset
      • getRemainingTime

        public long getRemainingTime​(java.time.temporal.TemporalUnit unit)
        Calculates the amount of time until getEndTime() in terms of the specified unit.
        If getEndTime() is null this will be negative.
        Parameters:
        unit - The TemporalUnit to return
        Returns:
        Remaining time in the provided TemporalUnit or -1 if unset
        Throws:
        java.lang.IllegalArgumentException - If the provided unit is null
        java.lang.ArithmeticException - If a numeric overflow occurs
        java.time.DateTimeException - If the amount cannot be calculated
        java.time.temporal.UnsupportedTemporalTypeException - If the provided unit is not supported
        See Also:
        Instant.until(Temporal, TemporalUnit), TemporalUnit
      • getElapsedTime

        public long getElapsedTime​(java.time.temporal.TemporalUnit unit)
        Calculates the elapsed time from getStartTime() to now in terms of the specified unit.
        If getStartTime() is null this will be negative.
        Parameters:
        unit - The TemporalUnit to return
        Returns:
        Elapsed time in the provided TemporalUnit or -1 if unset
        Throws:
        java.lang.IllegalArgumentException - If the provided unit is null
        java.lang.ArithmeticException - If a numeric overflow occurs
        java.time.DateTimeException - If the amount cannot be calculated
        java.time.temporal.UnsupportedTemporalTypeException - If the provided unit is not supported
        See Also:
        Instant.until(Temporal, TemporalUnit), TemporalUnit
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object