MCPcopy Create free account
hub / github.com/jwtk/jjwt / FixedClock

Class FixedClock

impl/src/main/java/io/jsonwebtoken/impl/FixedClock.java:28–64  ·  view source on GitHub ↗

A Clock implementation that is constructed with a seed timestamp and always reports that same timestamp. @since 0.7.0

Source from the content-addressed store, hash-verified

26 * @since 0.7.0
27 */
28public class FixedClock implements Clock {
29
30 private final Date now;
31
32 /**
33 * Creates a new fixed clock using <code>new {@link Date Date}()</code> as the seed timestamp. All calls to
34 * {@link #now now()} will always return this seed Date.
35 */
36 public FixedClock() {
37 this(new Date());
38 }
39
40 /**
41 * Creates a new fixed clock using the specified seed timestamp. All calls to
42 * {@link #now now()} will always return this seed Date.
43 *
44 * @param now the specified Date to always return from all calls to {@link #now now()}.
45 */
46 public FixedClock(Date now) {
47 this.now = now;
48 }
49
50 /**
51 * Creates a new fixed clock using the specified seed timestamp. All calls to
52 * {@link #now now()} will always return this seed Date.
53 *
54 * @param timeInMillis the specified Date in milliseconds to always return from all calls to {@link #now now()}.
55 */
56 public FixedClock(long timeInMillis) {
57 this(new Date(timeInMillis));
58 }
59
60 @Override
61 public Date now() {
62 return this.now;
63 }
64}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…