📜  java.time.Clock类

📅  最后修改于: 2020-11-14 10:41:23             🧑  作者: Mango


介绍

java.time.Clock类使用时区提供对当前时刻,日期和时间的访问。

类声明

以下是java.io.Clock类的声明-

public abstract class Clock
   extends Object

类的构造函数

Sr.No. Constructor & Description
1

protected Clock()

This creates a Clock.

类方法

Sr.No. Method & Description
1 boolean equals(Object obj)

This method checks if this clock is equal to another clock.

2 static Clock fixed(Instant fixedInstant, ZoneId zone)

This method obtains a clock that always returns the same instant.

3 abstract ZoneId getZone()

This method gets the time-zone being used to create dates and times.

4 int hashCode()

This method gets a hash code for this clock.

5 int instant()

This method gets the current instant of the clock.

6 long millis()

This method gets the current millisecond instant of the clock.

7 static Clock offset(Clock baseClock, Duration offsetDuration)

This method obtains a clock that returns instants from the specified clock with the specified duration added.

8 static Clock system(ZoneId zone)

This method obtains a clock that returns the current instant using best available system clock.

9 static Clock systemDefaultZone()

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

10 static Clock systemUTC()

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

11 static Clock tick(Clock baseClock, Duration tickDuration)

This method obtains a clock that returns instants from the specified clock truncated to the nearest occurrence of the specified duration.

12 static Clock tickMinutes(ZoneId zone)

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

13 static Clock tickSeconds(ZoneId zone)

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

14 static Clock withZone(ZoneId zone)

This method returns a copy of this clock with a different time-zone.

方法继承

此类从以下类继承方法-

  • Java.lang.Object