Here you can find the source of sleepToNextMinute()
public static boolean sleepToNextMinute()
//package com.java2s; //License from project: Apache License public class Main { public static final long ONE_MINUTE = 60 * 1000L; public static boolean sleepToNextMinute() { try {/*from w w w . j a v a 2 s . c o m*/ long current = System.currentTimeMillis(); Thread.sleep(ONE_MINUTE - current % ONE_MINUTE + 500); return true; } catch (InterruptedException e) { return false; } } }