- java.time - Home
- java.time - Clock
- java.time - Duration
- java.time - Instant
- java.time - LocalDate
- java.time - LocalDateTime
- java.time - LocalTime
- java.time - MonthDay
- java.time - OffsetDateTime
- java.time - OffsetTime
- java.time - Period
- java.time - Year
- java.time - YearMonth
- java.time - ZonedDateTime
- java.time - ZoneId
- java.time - ZoneOffset
- java.time Package Enums
- java.time - Month
- java.time Useful Resources
- java.time - Discussion
java.time.Clock Class
Introduction
The java.time.Clock class provides access to the current instant, date and time using a time-zone.
Class declaration
Following is the declaration for java.io.Clock class −
public abstract class Clock extends Object
Class constructors
| Sr.No. | Constructor & Description |
|---|---|
| 1 | protected Clock() This creates a Clock. |
Class methods
| 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. |
Methods inherited
This class inherits methods from the following classes −
- Java.lang.Object