# Class FixedClock (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.FixedClock)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.testing.http.FixedClock)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.testing.http.FixedClock)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.testing.http.FixedClock)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.testing.http.FixedClock)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.testing.http.FixedClock)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.testing.http.FixedClock)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.testing.http.FixedClock)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.testing.http.FixedClock)

    public class FixedClock implements Clock

[Beta](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Beta)   

A thread-safe fixed time implementation of the Clock to be used for unit testing.

Explicitly allows you to set the time to any arbitrary value.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> FixedClock

## Implements

[Clock](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Clock)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Constructors

### FixedClock()

    public FixedClock()

Initializes the FixedClock with 0 millis as start time.

### FixedClock(long startTime)

    public FixedClock(long startTime)

Initializes the FixedClock with the specified time.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `startTime` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` time in milliseconds used for initialization. |

## Methods

### currentTimeMillis()

    public long currentTimeMillis()

Returns the current time in milliseconds since midnight, January 1, 1970 UTC, to match the
behavior of System#currentTimeMillis().

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### setTime(long newTime)

    public FixedClock setTime(long newTime)

Changes the time value this time provider is returning.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `newTime` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` New time in milliseconds. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.FixedClock` |   |