Top Description Constructors Methods
org.eclipse.jgit.util.time

public abstract Class ProposedTimestamp

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Static Imports
java.util.concurrent.TimeUnit.MICROSECONDS, .TimeUnit.MILLISECONDS

A timestamp generated by org.eclipse.jgit.util.time.MonotonicClock#propose().

ProposedTimestamp implements AutoCloseable so that implementations can release resources associated with obtaining certainty about time elapsing. For example the constructing MonotonicClock may start network IO with peers when creating the ProposedTimestamp, and close() can ensure those network resources are released in a timely fashion.

Since
4.6

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
blockUntil(Iterable<ProposedTimestamp>
timestamps to wait on.
times
,
Duration
how long to wait for the timestamps.
maxWait
)

Wait for several timestamps.

public abstract void
blockUntil(Duration
how long the implementation may block the caller.
maxWait
)

Wait for this proposed timestamp to be certainly in the recent past.

public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public Date

Returns:

time since epoch, with up to millisecond resolution.
date
()
Deprecated since 7.2. Use instant() instead

Get time since epoch, with up to millisecond resolution.

public Instant

Returns:

time since epoch, with up to microsecond resolution.
instant
()

Get time since epoch, with up to microsecond resolution.

public long

Returns:

microseconds since epoch; read(MICROSECONDS).
micros
()

Get microseconds since epoch; read(MICROSECONDS).

public long

Returns:

milliseconds since epoch; read(MILLISECONDS).
millis
()

Get milliseconds since epoch; read(MILLISECONDS).

public abstract long

Returns:

unit since the epoch.
read
(TimeUnit
what unit to return the timestamp in. The timestamp will be rounded if the unit is bigger than the clock's granularity.
unit
)

Read the timestamp as unit since the epoch.

public java.sql.Timestamp

Returns:

time since epoch, with up to microsecond resolution.
timestamp
()
Deprecated since 7.2. Use instant() instead

Get time since epoch, with up to microsecond resolution.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Constructor Detail

ProposedTimestampback to summary
public ProposedTimestamp()

Method Detail

blockUntilback to summary
public static void blockUntil(Iterable<ProposedTimestamp> times, Duration maxWait) throws TimeoutException, InterruptedException

Wait for several timestamps.

Parameters
times:Iterable<ProposedTimestamp>

timestamps to wait on.

maxWait:Duration

how long to wait for the timestamps.

Exceptions
TimeoutException:
the timeout was reached without the proposed timestamp become certainly in the past.
InterruptedException:
current thread was interrupted before the waiting process completed normally.
blockUntilback to summary
public abstract void blockUntil(Duration maxWait) throws InterruptedException, TimeoutException

Wait for this proposed timestamp to be certainly in the recent past.

This method forces the caller to wait up to timeout for this to pass sufficiently into the past such that the creating org.eclipse.jgit.util.time.MonotonicClock instance will not create an earlier timestamp.

Parameters
maxWait:Duration

how long the implementation may block the caller.

Exceptions
InterruptedException:
current thread was interrupted before the waiting process completed normally.
TimeoutException:
the timeout was reached without the proposed timestamp becoming certainly in the past.
closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Release resources allocated by this timestamp.

Annotations
@Override
dateback to summary
public Date date()

Deprecated

since 7.2.

Use instant() instead

Get time since epoch, with up to millisecond resolution.

Returns:Date

time since epoch, with up to millisecond resolution.

Annotations
@Deprecated
since:7.2
instantback to summary
public Instant instant()

Get time since epoch, with up to microsecond resolution.

Returns:Instant

time since epoch, with up to microsecond resolution.

microsback to summary
public long micros()

Get microseconds since epoch; read(MICROSECONDS).

Returns:long

microseconds since epoch; read(MICROSECONDS).

millisback to summary
public long millis()

Get milliseconds since epoch; read(MILLISECONDS).

Returns:long

milliseconds since epoch; read(MILLISECONDS).

readback to summary
public abstract long read(TimeUnit unit)

Read the timestamp as unit since the epoch.

The timestamp value for a specific ProposedTimestamp object never changes, and can be read before blockUntil(Duration).

Parameters
unit:TimeUnit

what unit to return the timestamp in. The timestamp will be rounded if the unit is bigger than the clock's granularity.

Returns:long

unit since the epoch.

timestampback to summary
public java.sql.Timestamp timestamp()

Deprecated

since 7.2.

Use instant() instead

Get time since epoch, with up to microsecond resolution.

Returns:java.sql.Timestamp

time since epoch, with up to microsecond resolution.

Annotations
@Deprecated
since:7.2
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override