Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:52:59+00:00 2026-06-08T09:52:59+00:00

I am looking for the best way in Java to monitor the computer clock

  • 0

I am looking for the best way in Java to monitor the computer clock (the minutes) and to fire off a method/thread every time it changes.

So if the time is 13:20 and it changes to 13.21 then do something. So any time there is a minute change some code gets fired.

What is the best way to listen to the minute section of the clock for changes ?

Thanks,
Richard

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:53:00+00:00Added an answer on June 8, 2026 at 9:53 am
    1. Find the current system time using System.currentTimeMillis()
    2. Calculate how many milliseconds until the next minute
    3. Schedule a TimerTask on a Timer to run in that number of milliseconds in the future
    4. In that TimerTask’s event handler schedule a new reoccurring TimerTask to run every 60,000 milliseconds.

      int milisInAMinute = 60000;
      long time = System.currentTimeMillis();
      
      Runnable update = new Runnable() {
          public void run() {
              // Do whatever you want to do when the minute changes
          }
      };
      
      Timer timer = new Timer();
      timer.schedule(new TimerTask() {
          public void run() {
              update.run();
          }
      }, time % milisInAMinute, milisInAMinute);
      
      // This will update for the current minute, it will be updated again in at most one minute.
      update.run();
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for the best way to do a One Time Login for
I am looking for the best way to add milliseconds to a Java Date
I am looking for a best way to trigger windows application automation from Java
I'm looking for the best way to run a java app as a Windows
I am looking for the best way to make my desktop java program run
I'm looking for a best way that is available for Java developers to implement
What's the best way to call R functionality from within Java? I'm looking for
What's the best way to lazily initialize a collection, I'm specifically looking at Java.
I'm looking for best way of using session within zf application. At first I
Looking for the best way to set-up an iPhone project in XCode ... namely:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.