Time { public static void waitFor(UtcT time) { if (time != null) { long now = System.nanoTime(); long delta = Time.millisTo(time); long then = now + (delta * 1000000); while (delta > 0) { try { Thread.sleep(delta); } catch (InterruptedException e) { } delta = (then - System.nanoTime()) / 1000000; } } } private  Time(); static UtcT corbaTime(); static UtcT corbaTime(long unixTime); static UtcT corbaTime(java.util.Date date); static UtcT corbaFuture(long corbaUnits); static long millisTo(UtcT time); static boolean hasPassed(UtcT time); static UtcT earliest(UtcT timeA, UtcT timeB); static byte[] toCDR(UtcT time); static UtcT fromCDR(byte[] buffer); static void waitFor(UtcT time); static final long UNIX_OFFSET; }
@Test public void waitFor() { long now = System.nanoTime(); long later = now + ( 2 * 1000 * 1000000); Time.waitFor( new UtcT( (System.currentTimeMillis() + 5000 ) * 10000 + Time.UNIX_OFFSET, 0, (short)0, (short)0) ); assertTrue( System.nanoTime() >= later ); }