title: Duration#toMinutes in Runnable Every Second
body: <p>I have a Duration field tracking elapsed time (in minutes) in a Runnable that currently loops every minute. I want to make it run the loop every second instead, but my checks are firing off multiple times. Below is the gist of my code.</p>
  
  <pre><code>Runnable runnable = (new Runnable() {
      @Override
      public void run() {
          Instant now = Instant.now();
          Duration timeElapsed = Duration.between(start, now);
          long elapsedMinutes = timeElapsed.toMinutes();
          if (elapsedMinutes == (int) (totalRuntime() * .75)) {
              // Do something when partially done.
              // When set to second loops, this would run 60-ish times.
          }
      }
  });
  </code></pre>
  
  <p>I tried adding a check, basically as follows, seeing if the seconds divided by 60 was a whole number, though that also didn't work.</p>
  
  <pre><code>long elapsedSeconds = timeElapsed.getSeconds();
  if (elapsedSeconds / 60 == Math.round(elapsedSeconds / 60)) {
      // Then do other stuff
  }
  </code></pre>
  
  <p>Can someone suggest something I can do to ensure everything in the loop only gets run once per minute instead of once per second.</p>
  
  <p>You may also be asking why I'm making it a second instead of minute, it's because there's an if-statement wrapping the entire <code>run</code> method and it has to start something immediately if it doesn't pass.</p>