Package io.sentry

Class SentryDate

java.lang.Object
io.sentry.SentryDate
All Implemented Interfaces:
Comparable<SentryDate>
Direct Known Subclasses:
SentryInstantDate, SentryLongDate, SentryNanotimeDate

public abstract class SentryDate extends Object implements Comparable<SentryDate>
  • Constructor Details

    • SentryDate

      public SentryDate()
  • Method Details

    • nanoTimestamp

      public abstract long nanoTimestamp()
      Returns the date in nanoseconds as long.
    • laterDateNanosTimestampByDiff

      public long laterDateNanosTimestampByDiff(@Nullable @Nullable SentryDate otherDate)
      Calculates a date by using another date.

      This is a workaround for limited precision offered in some cases (e.g. when using SentryNanotimeDate). This makes it possible to have high precision duration by using nanoseconds for the finish timestamp where normally the start and finish timestamps would only offer millisecond precision.

      Parameters:
      otherDate - another SentryDate
      Returns:
      date in seconds as long
    • diff

      public long diff(@NotNull @NotNull SentryDate otherDate)
      Difference between two dates in nanoseconds.
      Parameters:
      otherDate - another SentryDate
      Returns:
      difference in nanoseconds
    • isBefore

      public final boolean isBefore(@NotNull @NotNull SentryDate otherDate)
    • isAfter

      public final boolean isAfter(@NotNull @NotNull SentryDate otherDate)
    • compareTo

      public int compareTo(@NotNull @NotNull SentryDate otherDate)
      Specified by:
      compareTo in interface Comparable<SentryDate>