List of utility methods to do TimeUnit Usage
boolean | waitFor(long period) wait For if (period > 0) { try { Thread.sleep(period); } catch (Exception e) { return false; } else Thread.yield(); ... |
void | waitFor(Object obj) wait For try { synchronized (obj) { obj.wait(); } catch (InterruptedException e) { |
boolean | waitFor(Semaphore semaphore, long timeoutInMillis) wait For return semaphore.tryAcquire(timeoutInMillis, TimeUnit.MILLISECONDS);
|
void | waitForMinutes(long time) wait For Minutes try { TimeUnit.MINUTES.sleep(time); } catch (InterruptedException e) { e.printStackTrace(); |
int | waitForProcess(Process process, String name) wait For Process return waitForProcess(process, name, true);
|
T | waitForResponseObject(BlockingQueue Polls the blocking queue, waiting up to the POLLING_TIMEOUT (in seconds) if necessary for an element to become available. return waitForResponseObject(queue, clazz, POLLING_TIMEOUT);
|
boolean | waitForSignal(CountDownLatch b) wait For Signal try { return b.await(timeoutSecs, TimeUnit.SECONDS); } catch (InterruptedException ie) { return false; |
long | weekendMinutesBetween(Date date1, Date date2) weekend Minutes Between Calendar date1Calendar = Calendar.getInstance(); date1Calendar.setTime(date1); long weekendMinutes = 0; date1Calendar.add(Calendar.DAY_OF_MONTH, 1); while (date2.after(date1Calendar.getTime())) { if (date1Calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || date1Calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { weekendMinutes += TimeUnit.DAYS.toMinutes(1); ... |
long | zeroOutMs(long timestamp) Cleans the milliseconds info from the timestamp return SECONDS.toMillis(MILLISECONDS.toSeconds(timestamp));
|