Class DateTimeStamp

  • All Implemented Interfaces:
    Comparable<DateTimeStamp>

    public class DateTimeStamp
    extends Object
    implements Comparable<DateTimeStamp>
    A date and time. Both date and time come from reading the GC log. In cases where the GC log has no date or time stamp, a DateTimeStamp is synthesized from the information available in the log (event durations, for example).

    Instance of DateTimeStamp are created by the parser. The constructors match what might be found for dates and time stamps in a GC log file.

    • Constructor Detail

      • DateTimeStamp

        public DateTimeStamp​(String iso8601DateTime)
        Create a DateTimeStamp by parsing an ISO 8601 date/time string.
        Parameters:
        iso8601DateTime - A String in ISO 8601 format.
      • DateTimeStamp

        public DateTimeStamp​(ZonedDateTime dateTime)
        Create a DateTimeStamp from a ZonedDateTime.
        Parameters:
        dateTime - A ZonedDateTime
      • DateTimeStamp

        public DateTimeStamp​(String iso8601DateTime,
                             double timeStamp)
        Create a DateTimeStamp from an IOS 8601 date/time string and a time stamp. The time stamp represents decimal seconds.
        Parameters:
        iso8601DateTime - A String in ISO 8601 format.
        timeStamp - A time stamp in decimal seconds.
      • DateTimeStamp

        public DateTimeStamp​(double timeStamp)
        Create a DateTimeStamp from a time stamp.
        Parameters:
        timeStamp - A time stamp in decimal seconds.
      • DateTimeStamp

        public DateTimeStamp​(ZonedDateTime dateTime,
                             double timeStamp)
        Create a DateTimeStamp from a ZonedDateTime and a timestamp. All other constructors end up here. If timeStamp is NaN or less than zero, then the time stamp is extracted from the ZonedDateTime.
        Parameters:
        dateTime - A ZonedDateTime, which may be null.
        timeStamp - A time stamp in decimal seconds, which should be greater than or equal to zero.
    • Method Detail

      • baseDate

        public static DateTimeStamp baseDate()
        Provides a minimal date.
        Returns:
        a minimal date
      • getTimeStamp

        @Deprecated
        public double getTimeStamp()
        Deprecated.
        Return the time stamp value. Allows a consistent time stamp be available to all calculations.
        Returns:
        The time stamp value, in decimal seconds.
      • toMilliseconds

        public double toMilliseconds()
      • toSeconds

        public double toSeconds()
      • getDateTime

        public ZonedDateTime getDateTime()
        Return the date stamp.
        Returns:
        The date stamp, which may be null
      • hasDateStamp

        public boolean hasDateStamp()
        Return true if the date stamp is not null. It is possible to have two DateTimeStamps from the same GC log, one with a DateStamp and one without.
        Returns:
        true if the date stamp is not null.
      • hasTimeStamp

        public boolean hasTimeStamp()
      • hashCode

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

        public boolean before​(DateTimeStamp other)
        Return true if this DateTimeStamp comes before the other.
        Parameters:
        other - The other DateTimeStamp.
        Returns:
        true if this time stamp is less than the other.
      • after

        public boolean after​(DateTimeStamp other)
        Return true if this DateTimeStamp comes after the other.
        Parameters:
        other - The other DateTimeStamp.
        Returns:
        true if this time stamp is less than the other.
      • compare

        public int compare​(ZonedDateTime otherDate)
        Return 1 if this date is after than the other, -1 if this date is before the other, or 0 if this date is the same as the other.
        Parameters:
        otherDate - The other date.
        Returns:
        1, 0, -1 if this date is after, the same as, or before the other.
      • add

        public DateTimeStamp add​(double offsetInDecimalSeconds)
        Return a new DateTimeStamp resulting from adding the decimal second offset to this.
        Parameters:
        offsetInDecimalSeconds - An offset, in decimal seconds.
        Returns:
        A new DateTimeStamp, offsetInDecimalSeconds from this.
      • minus

        public DateTimeStamp minus​(double offsetInDecimalSeconds)
        Return a new DateTimeStamp resulting from subtracting the decimal second offset from this.
        Parameters:
        offsetInDecimalSeconds - An offset, in decimal seconds.
        Returns:
        A new DateTimeStamp, offsetInDecimalSeconds from this.
      • minus

        public double minus​(DateTimeStamp other)
        Return the difference between this time stamp, and the time stamp of the other DateTimeStamp.
        Parameters:
        other - The other DateTimeStamp
        Returns:
        The difference between this time stamp, and the time stamp of the other DateTimeStamp.
      • timeSpanInMinutes

        public double timeSpanInMinutes​(DateTimeStamp dateTimeStamp)
        Return the difference between time stamps, converted to minutes. This is a convenience method for this.minus(dateTimeStamp) / 60.0.
        Parameters:
        dateTimeStamp - The other DateTimeStamp
        Returns:
        The difference between time stamps, converted to minutes.
      • compareTo

        public int compareTo​(DateTimeStamp dateTimeStamp)
        It will compare date time first, if both are equals then compare timestamp value, For Null date time considered to be last entry.
        Specified by:
        compareTo in interface Comparable<DateTimeStamp>
        Parameters:
        dateTimeStamp - - other object to compared
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
      • toEpochInMillis

        public double toEpochInMillis()