- java.lang.Object
-
- com.microsoft.gctoolkit.time.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.
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<DateTimeStamp>comparatorstatic DateTimeStampEMPTY_DATEstatic ZonedDateTimeEPOCstatic doubleTIMESTAMP_NOT_SET
-
Constructor Summary
Constructors Constructor Description DateTimeStamp(double timeStamp)Create a DateTimeStamp from a time stamp.DateTimeStamp(String iso8601DateTime)Create a DateTimeStamp by parsing an ISO 8601 date/time string.DateTimeStamp(String iso8601DateTime, double timeStamp)Create a DateTimeStamp from an IOS 8601 date/time string and a time stamp.DateTimeStamp(ZonedDateTime dateTime)Create a DateTimeStamp from a ZonedDateTime.DateTimeStamp(ZonedDateTime dateTime, double timeStamp)Create a DateTimeStamp from a ZonedDateTime and a timestamp.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DateTimeStampadd(double offsetInDecimalSeconds)Return a newDateTimeStampresulting from adding the decimal second offset to this.booleanafter(DateTimeStamp other)Returntrueif this DateTimeStamp comes after the other.static DateTimeStampbaseDate()Provides a minimal date.booleanbefore(DateTimeStamp other)Returntrueif this DateTimeStamp comes before the other.intcompare(ZonedDateTime otherDate)Return1if this date is after than the other,-1if this date is before the other, or0if this date is the same as the other.intcompareTo(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.booleanequals(Object obj)static DateTimeStampfromGCLogLine(String line)ZonedDateTimegetDateTime()Return the date stamp.doublegetTimeStamp()Deprecated.booleanhasDateStamp()Returntrueif the date stamp is notnull.inthashCode()booleanhasTimeStamp()DateTimeStampminus(double offsetInDecimalSeconds)Return a newDateTimeStampresulting from subtracting the decimal second offset from this.doubleminus(DateTimeStamp other)Return the difference between this time stamp, and the time stamp of the other DateTimeStamp.doubletimeSpanInMinutes(DateTimeStamp dateTimeStamp)Return the difference between time stamps, converted to minutes.doubletoEpochInMillis()doubletoMilliseconds()doubletoSeconds()StringtoString()
-
-
-
Field Detail
-
TIMESTAMP_NOT_SET
public static final double TIMESTAMP_NOT_SET
- See Also:
- Constant Field Values
-
EPOC
public static final ZonedDateTime EPOC
-
comparator
public static final Comparator<DateTimeStamp> comparator
-
EMPTY_DATE
public static final DateTimeStamp EMPTY_DATE
-
-
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 isNaNor less than zero, then the time stamp is extracted from the ZonedDateTime.- Parameters:
dateTime- A ZonedDateTime, which may benull.timeStamp- A time stamp in decimal seconds, which should be greater than or equal to zero.
-
-
Method Detail
-
fromGCLogLine
public static DateTimeStamp fromGCLogLine(String line)
-
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()
Returntrueif the date stamp is notnull. It is possible to have two DateTimeStamps from the same GC log, one with a DateStamp and one without.- Returns:
trueif the date stamp is notnull.
-
hasTimeStamp
public boolean hasTimeStamp()
-
before
public boolean before(DateTimeStamp other)
Returntrueif this DateTimeStamp comes before the other.- Parameters:
other- The other DateTimeStamp.- Returns:
trueif this time stamp is less than the other.
-
after
public boolean after(DateTimeStamp other)
Returntrueif this DateTimeStamp comes after the other.- Parameters:
other- The other DateTimeStamp.- Returns:
trueif this time stamp is less than the other.
-
compare
public int compare(ZonedDateTime otherDate)
Return1if this date is after than the other,-1if this date is before the other, or0if this date is the same as the other.- Parameters:
otherDate- The other date.- Returns:
1,0,-1if this date is after, the same as, or before the other.
-
add
public DateTimeStamp add(double offsetInDecimalSeconds)
Return a newDateTimeStampresulting from adding the decimal second offset to this.- Parameters:
offsetInDecimalSeconds- An offset, in decimal seconds.- Returns:
- A new
DateTimeStamp,offsetInDecimalSecondsfrom this.
-
minus
public DateTimeStamp minus(double offsetInDecimalSeconds)
Return a newDateTimeStampresulting from subtracting the decimal second offset from this.- Parameters:
offsetInDecimalSeconds- An offset, in decimal seconds.- Returns:
- A new
DateTimeStamp,offsetInDecimalSecondsfrom 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 otherDateTimeStamp- 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 forthis.minus(dateTimeStamp) / 60.0.- Parameters:
dateTimeStamp- The otherDateTimeStamp- 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:
compareToin interfaceComparable<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()
-
-