# Clock

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Clock

```
abstract class Clock : InstantSource
```

|---|------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)     ||
| ↳ | [java.time.Clock](https://developer.android.com/reference/kotlin/java/time/Clock#) |

A clock providing access to the current instant, date and time using a time-zone.

Instances of this abstract class are used to access a pluggable representation of the current instant, which can be interpreted using the stored time-zone to find the current date and time. For example,`Clock`can be used instead of[System.currentTimeMillis()](https://developer.android.com/reference/kotlin/java/lang/System.html#currentTimeMillis())and[TimeZone.getDefault()](https://developer.android.com/reference/kotlin/java/util/TimeZone.html#getDefault()).

Use of a`Clock`is optional. All key date-time classes also have a`now()`factory method that uses the system clock in the default time zone. The primary purpose of this abstraction is to allow alternate clocks to be plugged in as and when required. Applications use an object to obtain the current time rather than a static method. This can simplify testing.

As such, this abstract class does not guarantee the result actually represents the current instant on the time-line. Instead, it allows the application to provide a controlled view as to what the current instant and time-zone are.

Best practice for applications is to pass a`Clock`into any method that requires the current instant and time-zone. A dependency injection framework is one way to achieve this:  

```kotlin
public class MyBean {
     private Clock clock;  // dependency inject
     ...
     public void process(LocalDate eventDate) {
       if (eventDate.isBefore(LocalDate.now(clock)) {
         ...
       }
     }
   }
  
```
This approach allows an alternative clock, such as[fixed](https://developer.android.com/reference/kotlin/java/time/Clock#fixed(java.time.Instant,%20java.time.ZoneId))or[offset](https://developer.android.com/reference/kotlin/java/time/Clock#offset(java.time.Clock,%20java.time.Duration))to be used during testing.

The`system`factory methods provide clocks based on the best available system clock. This may use[System.currentTimeMillis()](https://developer.android.com/reference/kotlin/java/lang/System.html#currentTimeMillis()), or a higher resolution clock if one is available.

## Summary

|                                                    Protected constructors                                                    ||
|---------------------------------------------------------------------------------------------------------------------------|---|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#Clock())`()` Constructor accessible by subclasses. |

|                                                                                                                                                                                                                                                             Public methods                                                                                                                                                                                                                                                             ||
|----------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [equals](https://developer.android.com/reference/kotlin/java/time/Clock#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` Checks if this clock is equal to another clock.                                                                                                                                                                                                          |
| openstatic[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!    | [fixed](https://developer.android.com/reference/kotlin/java/time/Clock#fixed(java.time.Instant,%20java.time.ZoneId))`(`fixedInstant:` `[Instant](https://developer.android.com/reference/kotlin/java/time/Instant)!`, `zone:` `[ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!`)` Obtains a clock that always returns the same instant.                                                                             |
| abstract[ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!     | [getZone](https://developer.android.com/reference/kotlin/java/time/Clock#getZone())`()` Gets the time-zone being used to create dates and times.                                                                                                                                                                                                                                                                                               |
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [hashCode](https://developer.android.com/reference/kotlin/java/time/Clock#hashCode())`()` A hash code for this clock.                                                                                                                                                                                                                                                                                                                          |
| abstract[Instant](https://developer.android.com/reference/kotlin/java/time/Instant)!   | [instant](https://developer.android.com/reference/kotlin/java/time/Clock#instant())`()` Gets the current instant of the clock.                                                                                                                                                                                                                                                                                                                 |
| open[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)       | [millis](https://developer.android.com/reference/kotlin/java/time/Clock#millis())`()` Gets the current millisecond instant of the clock.                                                                                                                                                                                                                                                                                                       |
| openstatic[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!    | [offset](https://developer.android.com/reference/kotlin/java/time/Clock#offset(java.time.Clock,%20java.time.Duration))`(`baseClock:` `[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!`, `offsetDuration:` `[Duration](https://developer.android.com/reference/kotlin/java/time/Duration)!`)` Obtains a clock that returns instants from the specified clock with the specified duration added.                       |
| openstatic[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!    | [system](https://developer.android.com/reference/kotlin/java/time/Clock#system(java.time.ZoneId))`(`zone:` `[ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!`)` Obtains a clock that returns the current instant using the best available system clock.                                                                                                                                                              |
| openstatic[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!    | [systemDefaultZone](https://developer.android.com/reference/kotlin/java/time/Clock#systemDefaultZone())`()` Obtains a clock that returns the current instant using the best available system clock, converting to date and time using the default time-zone.                                                                                                                                                                                   |
| openstatic[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!    | [systemUTC](https://developer.android.com/reference/kotlin/java/time/Clock#systemUTC())`()` Obtains a clock that returns the current instant using the best available system clock, converting to date and time using the UTC time-zone.                                                                                                                                                                                                       |
| openstatic[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!    | [tick](https://developer.android.com/reference/kotlin/java/time/Clock#tick(java.time.Clock,%20java.time.Duration))`(`baseClock:` `[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!`, `tickDuration:` `[Duration](https://developer.android.com/reference/kotlin/java/time/Duration)!`)` Obtains a clock that returns instants from the specified clock truncated to the nearest occurrence of the specified duration. |
| openstatic[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!    | [tickMillis](https://developer.android.com/reference/kotlin/java/time/Clock#tickMillis(java.time.ZoneId))`(`zone:` `[ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!`)` Obtains a clock that returns the current instant ticking in whole milliseconds using the best available system clock.                                                                                                                        |
| openstatic[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!    | [tickMinutes](https://developer.android.com/reference/kotlin/java/time/Clock#tickMinutes(java.time.ZoneId))`(`zone:` `[ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!`)` Obtains a clock that returns the current instant ticking in whole minutes using the best available system clock.                                                                                                                           |
| openstatic[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!    | [tickSeconds](https://developer.android.com/reference/kotlin/java/time/Clock#tickSeconds(java.time.ZoneId))`(`zone:` `[ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!`)` Obtains a clock that returns the current instant ticking in whole seconds using the best available system clock.                                                                                                                           |
| abstract[Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!      | [withZone](https://developer.android.com/reference/kotlin/java/time/Clock#withZone(java.time.ZoneId))`(`zone:` `[ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!`)` Returns a copy of this clock with a different time-zone.                                                                                                                                                                                         |

## Protected constructors

### Clock

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
protected Clock()
```

Constructor accessible by subclasses.

## Public methods

### equals

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun equals(other: Any?): Boolean
```

Checks if this clock is equal to another clock.

Clocks should override this method to compare equals based on their state and to meet the contract of[Object.equals](https://developer.android.com/reference/kotlin/java/lang/Object.html#equals(kotlin.Any)). If not overridden, the behavior is defined by[Object.equals](https://developer.android.com/reference/kotlin/java/lang/Object.html#equals(kotlin.Any))

|                   Parameters                   ||
|-------|-----------------------------------------|
| `obj` | the object to check, null returns false |

|                                                            Return                                                            ||
|------------------------------------------------------------------------------------|------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if this is equal to the other clock |

### fixed

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun fixed(
    fixedInstant: Instant!, 
    zone: ZoneId!
): Clock!
```

Obtains a clock that always returns the same instant.

This clock simply returns the specified instant. As such, it is not a clock in the conventional sense. The main use case for this is in testing, where the fixed clock ensures tests are not dependent on the current clock.

The returned implementation is immutable, thread-safe and`Serializable`.

|                                                                          Parameters                                                                           ||
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `fixedInstant` | [Instant](https://developer.android.com/reference/kotlin/java/time/Instant)!:the instant to use as the clock, not null                        |
| `zone`         | [ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!:the time-zone to use to convert the instant to date-time, not null |

|                                                              Return                                                               ||
|---------------------------------------------------------------------------|--------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock that always returns the same instant, not null |

### getZone

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun getZone(): ZoneId!
```

Gets the time-zone being used to create dates and times.

A clock will typically obtain the current instant and then convert that to a date or time using a time-zone. This method returns the time-zone used.

|                                                                Return                                                                ||
|----------------------------------------------------------------------------|----------------------------------------------------------|
| [ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)! | the time-zone being used to interpret instants, not null |

### hashCode

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun hashCode(): Int
```

A hash code for this clock.

Clocks should override this method based on their state and to meet the contract of[Object.hashCode](https://developer.android.com/reference/kotlin/java/lang/Object.html#hashCode()). If not overridden, the behavior is defined by[Object.hashCode](https://developer.android.com/reference/kotlin/java/lang/Object.html#hashCode())

|                                              Return                                              ||
|----------------------------------------------------------------------------|----------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a suitable hash code |

### instant

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun instant(): Instant!
```

Gets the current instant of the clock.

This returns an instant representing the current instant as defined by the clock.

|                                                           Return                                                            ||
|------------------------------------------------------------------------------|-----------------------------------------------|
| [Instant](https://developer.android.com/reference/kotlin/java/time/Instant)! | the current instant from this clock, not null |

|                                              Exceptions                                              ||
|-------------------------------|-----------------------------------------------------------------------|
| `java.time.DateTimeException` | if the instant cannot be obtained, not thrown by most implementations |

### millis

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun millis(): Long
```

Gets the current millisecond instant of the clock.

This returns the millisecond-based instant, measured from 1970-01-01T00:00Z (UTC). This is equivalent to the definition of[System.currentTimeMillis()](https://developer.android.com/reference/kotlin/java/lang/System.html#currentTimeMillis()).

Most applications should avoid this method and use[Instant](https://developer.android.com/reference/kotlin/java/time/Instant)to represent an instant on the time-line rather than a raw millisecond value. This method is provided to allow the use of the clock in high performance use cases where the creation of an object would be unacceptable.

The default implementation currently calls[instant](https://developer.android.com/reference/kotlin/java/time/Clock#instant()).

|                                                                                              Return                                                                                              ||
|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | the current millisecond instant from this clock, measured from the Java epoch of 1970-01-01T00:00Z (UTC), not null |

|                                              Exceptions                                              ||
|-------------------------------|-----------------------------------------------------------------------|
| `java.time.DateTimeException` | if the instant cannot be obtained, not thrown by most implementations |

### offset

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun offset(
    baseClock: Clock!, 
    offsetDuration: Duration!
): Clock!
```

Obtains a clock that returns instants from the specified clock with the specified duration added.

This clock wraps another clock, returning instants that are later by the specified duration. If the duration is negative, the instants will be earlier than the current date and time. The main use case for this is to simulate running in the future or in the past.

A duration of zero would have no offsetting effect. Passing zero will return the underlying clock.

The returned implementation is immutable, thread-safe and`Serializable`providing that the base clock is.

|                                                                 Parameters                                                                  ||
|------------------|---------------------------------------------------------------------------------------------------------------------------|
| `baseClock`      | [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!:the base clock to add the duration to, not null |
| `offsetDuration` | [Duration](https://developer.android.com/reference/kotlin/java/time/Duration)!:the duration to add, not null              |

|                                                                    Return                                                                    ||
|---------------------------------------------------------------------------|-------------------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock based on the base clock with the duration added, not null |

### system

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun system(zone: ZoneId!): Clock!
```

Obtains a clock that returns the current instant using the best available system clock.

This clock is based on the best available system clock. This may use[System.currentTimeMillis()](https://developer.android.com/reference/kotlin/java/lang/System.html#currentTimeMillis()), or a higher resolution clock if one is available.

Conversion from instant to date or time uses the specified time-zone.

The returned implementation is immutable, thread-safe and`Serializable`.

|                                                                      Parameters                                                                       ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `zone` | [ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!:the time-zone to use to convert the instant to date-time, not null |

|                                                                            Return                                                                            ||
|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock that uses the best available system clock in the specified zone, not null |

### systemDefaultZone

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun systemDefaultZone(): Clock!
```

Obtains a clock that returns the current instant using the best available system clock, converting to date and time using the default time-zone.

This clock is based on the best available system clock. This may use[System.currentTimeMillis()](https://developer.android.com/reference/kotlin/java/lang/System.html#currentTimeMillis()), or a higher resolution clock if one is available.

Using this method hard codes a dependency to the default time-zone into your application. It is recommended to avoid this and use a specific time-zone whenever possible. The[UTC clock](https://developer.android.com/reference/kotlin/java/time/Clock#systemUTC())should be used when you need the current instant without the date or time.

The returned implementation is immutable, thread-safe and`Serializable`. It is equivalent to`system(ZoneId.systemDefault())`.

|                                                                           Return                                                                           ||
|---------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock that uses the best available system clock in the default zone, not null |

**See Also**

- [java.time.ZoneId#systemDefault()](https://developer.android.com/reference/kotlin/java/time/ZoneId#systemDefault())  

### systemUTC

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun systemUTC(): Clock!
```

Obtains a clock that returns the current instant using the best available system clock, converting to date and time using the UTC time-zone.

This clock, rather than[systemDefaultZone()](https://developer.android.com/reference/kotlin/java/time/Clock#systemDefaultZone()), should be used when you need the current instant without the date or time.

This clock is based on the best available system clock. This may use[System.currentTimeMillis()](https://developer.android.com/reference/kotlin/java/lang/System.html#currentTimeMillis()), or a higher resolution clock if one is available.

Conversion from instant to date or time uses the[UTC time-zone](https://developer.android.com/reference/kotlin/java/time/ZoneOffset#UTC:java.time.ZoneOffset).

The returned implementation is immutable, thread-safe and`Serializable`. It is equivalent to`system(ZoneOffset.UTC)`.

|                                                                         Return                                                                         ||
|---------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock that uses the best available system clock in the UTC zone, not null |

### tick

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun tick(
    baseClock: Clock!, 
    tickDuration: Duration!
): Clock!
```

Obtains a clock that returns instants from the specified clock truncated to the nearest occurrence of the specified duration.

This clock will only tick as per the specified duration. Thus, if the duration is half a second, the clock will return instants truncated to the half second.

The tick duration must be positive. If it has a part smaller than a whole millisecond, then the whole duration must divide into one second without leaving a remainder. All normal tick durations will match these criteria, including any multiple of hours, minutes, seconds and milliseconds, and sensible nanosecond durations, such as 20ns, 250,000ns and 500,000ns.

A duration of zero or one nanosecond would have no truncation effect. Passing one of these will return the underlying clock.

Implementations may use a caching strategy for performance reasons. As such, it is possible that the start of the requested duration observed via this clock will be later than that observed directly via the underlying clock.

The returned implementation is immutable, thread-safe and`Serializable`providing that the base clock is.

|                                                                        Parameters                                                                        ||
|----------------|------------------------------------------------------------------------------------------------------------------------------------------|
| `baseClock`    | [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)!:the base clock to base the ticking clock on, not null          |
| `tickDuration` | [Duration](https://developer.android.com/reference/kotlin/java/time/Duration)!:the duration of each visible tick, not negative, not null |

|                                                                 Return                                                                 ||
|---------------------------------------------------------------------------|-------------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock that ticks in whole units of the duration, not null |

|                                                                                   Exceptions                                                                                    ||
|--------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | if the duration is negative, or has a part smaller than a whole millisecond such that the whole duration is not divisible into one second |
| `java.lang.ArithmeticException`      | if the duration is too large to be represented as nanos                                                                                   |

### tickMillis

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun tickMillis(zone: ZoneId!): Clock!
```

Obtains a clock that returns the current instant ticking in whole milliseconds using the best available system clock.

This clock will always have the nano-of-second field truncated to milliseconds. This ensures that the visible time ticks in whole milliseconds. The underlying clock is the best available system clock, equivalent to using[system(java.time.ZoneId)](https://developer.android.com/reference/kotlin/java/time/Clock#system(java.time.ZoneId)).

Implementations may use a caching strategy for performance reasons. As such, it is possible that the start of the millisecond observed via this clock will be later than that observed directly via the underlying clock.

The returned implementation is immutable, thread-safe and`Serializable`. It is equivalent to`tick(system(zone), Duration.ofMillis(1))`.

|                                                                      Parameters                                                                       ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `zone` | [ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!:the time-zone to use to convert the instant to date-time, not null |

|                                                                         Return                                                                         ||
|---------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock that ticks in whole milliseconds using the specified zone, not null |

### tickMinutes

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun tickMinutes(zone: ZoneId!): Clock!
```

Obtains a clock that returns the current instant ticking in whole minutes using the best available system clock.

This clock will always have the nano-of-second and second-of-minute fields set to zero. This ensures that the visible time ticks in whole minutes. The underlying clock is the best available system clock, equivalent to using[system(java.time.ZoneId)](https://developer.android.com/reference/kotlin/java/time/Clock#system(java.time.ZoneId)).

Implementations may use a caching strategy for performance reasons. As such, it is possible that the start of the minute observed via this clock will be later than that observed directly via the underlying clock.

The returned implementation is immutable, thread-safe and`Serializable`. It is equivalent to`tick(system(zone), Duration.ofMinutes(1))`.

|                                                                      Parameters                                                                       ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `zone` | [ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!:the time-zone to use to convert the instant to date-time, not null |

|                                                                      Return                                                                       ||
|---------------------------------------------------------------------------|------------------------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock that ticks in whole minutes using the specified zone, not null |

### tickSeconds

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun tickSeconds(zone: ZoneId!): Clock!
```

Obtains a clock that returns the current instant ticking in whole seconds using the best available system clock.

This clock will always have the nano-of-second field set to zero. This ensures that the visible time ticks in whole seconds. The underlying clock is the best available system clock, equivalent to using[system(java.time.ZoneId)](https://developer.android.com/reference/kotlin/java/time/Clock#system(java.time.ZoneId)).

Implementations may use a caching strategy for performance reasons. As such, it is possible that the start of the second observed via this clock will be later than that observed directly via the underlying clock.

The returned implementation is immutable, thread-safe and`Serializable`. It is equivalent to`tick(system(zone), Duration.ofSeconds(1))`.

|                                                                      Parameters                                                                       ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `zone` | [ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!:the time-zone to use to convert the instant to date-time, not null |

|                                                                      Return                                                                       ||
|---------------------------------------------------------------------------|------------------------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock that ticks in whole seconds using the specified zone, not null |

### withZone

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun withZone(zone: ZoneId!): Clock!
```

Returns a copy of this clock with a different time-zone.

A clock will typically obtain the current instant and then convert that to a date or time using a time-zone. This method returns a clock with similar properties but using a different time-zone.

|                                                       Parameters                                                        ||
|--------|-----------------------------------------------------------------------------------------------------------------|
| `zone` | [ZoneId](https://developer.android.com/reference/kotlin/java/time/ZoneId)!:the time-zone to change to, not null |

|                                                                    Return                                                                     ||
|---------------------------------------------------------------------------|--------------------------------------------------------------------|
| [Clock](https://developer.android.com/reference/kotlin/java/time/Clock#)! | a clock based on this clock with the specified time-zone, not null |