java.time.Clock.tickMinutes() Method Example



Description

The java.time.Clock.tickMinutes() method obtains a clock that returns the current instant ticking in whole minutes using best available system clock.

Declaration

Following is the declaration for java.time.Clock.tickMinutes() method.

public static Clock tickMinutes(ZoneId zone)

Parameters

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

Return Value

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

Example

The following example shows the usage of java.time.Clock.tickMinutes() method.

package com.tutorialspoint;

import java.time.Clock;
import java.time.ZoneId;

public class ClockDemo {
   public static void main(String[] args) {
   
      Clock clock = Clock.systemDefaultZone();
      Clock clock1 = Clock.tickMinutes(ZoneId.systemDefault());
      System.out.println("Clock : " + clock.instant());
      System.out.println("Clock1 : " + clock1.instant());
   }
}

Let us compile and run the above program, this will produce the following result −

Clock : 2017-03-07T06:56:53.522Z
Clock1 : 2017-03-07T06:56:00Z
Advertisements