Java Clock Class | tickMinutes() Method with Example

Clock Class tickMinutes() method: Here, we are going to learn about the tickMinutes() method of Clock Class with its syntax and example.
Submitted by Preeti Jain, on May 13, 2020

Clock Class tickMinutes() method

  • tickMinutes() method is available in java.time package.
  • tickMinutes() method is used to get a Clock that returns the current instant that uses a suitable system clock in the given zone (zo) to tick in whole minutes.
  • tickMinutes() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get an error.
  • tickMinutes() method does not throw an exception at the time of representing Clock.


    public static Clock tickMinutes(ZoneId zo);


  • ZoneId zo – represents the zone to translate the clock instant to date:time.

Return value:

The return type of this method is Clock, it returns Clock that ticks in whole minutes of the given zone.


// Java program to demonstrate the example 
// of tickMinutes(ZoneId zo) method of Clock

import java.time.*;

public class TickMinutesOfClock {
    public static void main(String args[]) {
        // Instantiates two ZoneId for Accra and Asmara
        ZoneId zone_1 = ZoneId.of("Africa/Accra");
        ZoneId zone_2 = ZoneId.of("Africa/Asmara");

        // Initialize two Clock objects 
        Clock cl1 = Clock.system(zone_1);
        Clock cl2 = Clock.system(zone_2);

        // generates a new Clock that
        // returns the current instant ticking in 
        // whole minutes by using the given zone_1
        Clock cl_tick_min = Clock.tickMinutes(zone_1);

        // Display cl1 and cl_tick_min instant
        System.out.println("cl1.instant(): " + cl1.instant());
        System.out.println("cl_tick_min.instant(): " + cl_tick_min.instant());


        // generates a new Clock that
        // returns the current instant ticking in 
        // whole minutes by using the given zone_2
        cl_tick_min = Clock.tickMinutes(zone_2);

        // Display cl2 and cl_tick_min instant
        System.out.println("cl2.instant(): " + cl2.instant());
        System.out.println("cl_tick_min.instant(): " + cl_tick_min.instant());


cl1.instant(): 2020-05-13T21:50:41.477620Z
cl_tick_min.instant(): 2020-05-13T21:50:00Z

cl2.instant(): 2020-05-13T21:50:41.533121Z
cl_tick_min.instant(): 2020-05-13T21:50:00Z


Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.