Package org.bitcoinj.base.internal
Class TimeUtils
java.lang.Object
org.bitcoinj.base.internal.TimeUtils
Utilities for time and mock time.
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears the mock clock and causes time to tick again.static InstantReturns the current time as an Instant, or a mocked out equivalent.static StringdateTimeFormat(Instant time) Formats a given date+time value to an ISO 8601 string.static InstantDetermines the earlier of two instants.static DurationelapsedTime(Instant start) Returns elapsed time between given start and current time as a Duration.static InstantDetermines the later of two instants.static DurationDetermines the longest of two durations.static voidrollMockClock(Duration delta) Rolls an already set mock clock by the given duration.static voidSets the mock clock to the current time as a fixed instant.static voidsetMockClock(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
 
 -