Object/Class

java.time

Clock

Related Docs: class Clock | package time

Permalink

object Clock

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Clock
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. def fixed(fixedInstant: Instant, zone: ZoneId): Clock

    Permalink

    Obtains a clock that always returns the same instant.

    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.

    fixedInstant

    the instant to use as the clock, not null

    zone

    the time-zone to use to convert the instant to date-time, not null

    returns

    a clock that always returns the same instant, not null

  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. def offset(baseClock: Clock, offsetDuration: Duration): Clock

    Permalink

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

    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.

    baseClock

    the base clock to add the duration to, not null

    offsetDuration

    the duration to add, not null

    returns

    a clock based on the base clock with the duration added, not null

  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  18. def system(zone: ZoneId): Clock

    Permalink

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

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

    This clock is based on the best available system clock. This may use System#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.

    zone

    the time-zone to use to convert the instant to date-time, not null

    returns

    a clock that uses the best available system clock in the specified zone, not null

  19. def systemDefaultZone: Clock

    Permalink

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

    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(), 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 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()).

    returns

    a clock that uses the best available system clock in the default zone, not null

    See also

    ZoneId#systemDefault()

  20. def systemUTC: Clock

    Permalink

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

    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(), 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(), or a higher resolution clock if one is available.

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

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

    returns

    a clock that uses the best available system clock in the UTC zone, not null

  21. def tick(baseClock: Clock, tickDuration: Duration): Clock

    Permalink

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

    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.

    baseClock

    the base clock to base the ticking clock on, not null

    tickDuration

    the duration of each visible tick, not negative, not null

    returns

    a clock that ticks in whole units of the duration, not null

    Exceptions thrown

    ArithmeticException if the duration is too large to be represented as nanos

    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

  22. def tickMinutes(zone: ZoneId): Clock

    Permalink

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

    Obtains a clock that returns the current instant ticking in whole minutes using 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(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)).

    zone

    the time-zone to use to convert the instant to date-time, not null

    returns

    a clock that ticks in whole minutes using the specified zone, not null

  23. def tickSeconds(zone: ZoneId): Clock

    Permalink

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

    Obtains a clock that returns the current instant ticking in whole seconds using 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(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)).

    zone

    the time-zone to use to convert the instant to date-time, not null

    returns

    a clock that ticks in whole seconds using the specified zone, not null

  24. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  25. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped