Package org.bitcoinj.base.internal
Class TimeUtils
java.lang.Object
org.bitcoinj.base.internal.TimeUtils
Utilities for time and mock time.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clears the mock clock and causes time to tick again.static Instant
Returns the current time as an Instant, or a mocked out equivalent.static String
dateTimeFormat
(Instant time) Formats a given date+time value to an ISO 8601 string.static Instant
Determines the earlier of two instants.static Duration
elapsedTime
(Instant start) Returns elapsed time between given start and current time as a Duration.static Instant
Determines the later of two instants.static Duration
Determines the longest of two durations.static void
rollMockClock
(Duration delta) Rolls an already set mock clock by the given duration.static void
Sets the mock clock to the current time as a fixed instant.static void
setMockClock
(Instant fixedInstant) Sets the mock clock to a fixed instant.
-
Constructor Details
-
TimeUtils
public TimeUtils()
-
-
Method Details
-
setMockClock
public static void setMockClock()Sets the mock clock to the current time as a fixed instant. -
setMockClock
Sets the mock clock to a fixed instant.- Parameters:
fixedInstant
- a fixed instant
-
rollMockClock
Rolls an already set mock clock by the given duration.- Parameters:
delta
- amount to roll the mock clock, can be negative- Throws:
IllegalStateException
- if the mock clock isn't set
-
clearMockClock
public static void clearMockClock()Clears the mock clock and causes time to tick again. -
currentTime
Returns the current time as an Instant, or a mocked out equivalent. -
elapsedTime
Returns elapsed time between given start and current time as a Duration.Note that this method is affected by the mock clock. If you want to raise real debug data use
Stopwatch
. -
earlier
Determines the earlier of two instants. -
later
Determines the later of two instants. -
longest
Determines the longest of two durations. -
dateTimeFormat
Formats a given date+time value to an ISO 8601 string.- Parameters:
time
- date and time to format
-