Class PositiveTimestamp


  • public class PositiveTimestamp
    extends Object
    A timestamp that refers to a date after 1 January 1970. # Invariants The Unix timestamp representing the stored time has to be positive and no greater than [`MAX_TIMESTAMP`].
    • Method Detail

      • eq

        public boolean eq​(PositiveTimestamp b)
        Checks if two PositiveTimestamps contain equal inner contents. This ignores pointers and is_owned flags and looks at the values in fields. Two objects with NULL inner values will be considered "equal" here.
      • hash

        public long hash()
        Generates a non-cryptographic 64-bit hash of the PositiveTimestamp.
      • hashCode

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

        public static Result_PositiveTimestampCreationErrorZ from_unix_timestamp​(long unix_seconds)
        Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`. Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
      • from_system_time

        public static Result_PositiveTimestampCreationErrorZ from_system_time​(long time)
        Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in the range `0..=MAX_TIMESTAMP`. Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices. Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
      • from_duration_since_epoch

        public static Result_PositiveTimestampCreationErrorZ from_duration_since_epoch​(long duration)
        Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range `0..=MAX_TIMESTAMP`. Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices. Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
      • as_unix_timestamp

        public long as_unix_timestamp()
        Returns the Unix timestamp representing the stored time
      • as_duration_since_epoch

        public long as_duration_since_epoch()
        Returns the duration of the stored time since the Unix epoch
      • as_time

        public long as_time()
        Returns the [`SystemTime`] representing the stored time