### Question:
UUIDUtils { public static java.util.UUID newTimeUUID() { return UUIDGenerator.newTimeUUID(); }  static java.util.UUID newTimeUUID(); static UUID newTimeUUID( long ts, int timeoffset ); static UUID newTimeUUID( long ts ); static UUID maxTimeUUID( long ts ); static UUID min( UUID first, UUID second ); static UUID max( UUID first, UUID second ); static UUID decrement( UUID uuid ); static boolean isTimeBased( UUID uuid ); static long getTimestampInMillis( UUID uuid ); static long getTimestampInMicros( UUID uuid ); static UUID tryGetUUID( String s ); static boolean isUUID( String s ); static UUID tryExtractUUID( String s ); static UUID tryExtractUUID( String s, int offset ); static String toBase64( UUID id ); static UUID fromBase64( String str ); static int compare( UUID u1, UUID u2 ); static List<UUID> sort( List<UUID> uuids ); static final UUID MIN_TIME_UUID; static final UUID MAX_TIME_UUID; static final UUID ZERO_UUID; }### Answer:
@Test public void testAppProvidedTimestampOrdering() { logger.info("UUIDUtilsTest.testAppProvidedTimestamp"); long ts = System.currentTimeMillis(); System.out.println( ts ); UUID first = newTimeUUID( ts, 0 ); UUID second = newTimeUUID( ts, 1 ); assertFalse( first.equals( second ) ); assertTrue( first.compareTo( second ) < 0 ); }
@Test public void timeUUIDOrderingGaps() throws InterruptedException { UUID now1 = newTimeUUID(); UUID now2 = newTimeUUID(); Thread.sleep( 1 ); long start = System.currentTimeMillis(); UUID t1 = newTimeUUID( start, 0 ); UUID t2 = newTimeUUID( start, 1 ); TimeUnit.MILLISECONDS.sleep( 1 ); UUID now3 = newTimeUUID(); assertEquals( -1, now1.compareTo( t1 ) ); assertEquals( -1, now2.compareTo( t1 ) ); assertEquals( -1, now1.compareTo( t2 ) ); assertEquals( -1, now2.compareTo( t2 ) ); assertEquals( -1, t1.compareTo( now3 ) ); assertEquals( -1, t2.compareTo( now3 ) ); }