@Test public void timeBasedRandomMinLength() { int length = 17; String id = UnsafeIDGenerator.timeBasedRandom(length); Assert.assertNotEquals(length, id.length()); Assert.assertEquals(UnsafeIDGenerator.TIME_BASED_RANDOM_MIN_LENGTH, id.length()); System.out.println(id); }
public static String timeBasedRandom(int length) { String date = DateValues.toString(new Date(), TIME_FORMAT, UTC_TIME_ZONE); if (length < TIME_BASED_RANDOM_MIN_LENGTH) length = TIME_BASED_RANDOM_MIN_LENGTH; return date + random(length - TIME_FORMAT.length()); }
UnsafeIDGenerator { public static String timeBasedRandom(int length) { String date = DateValues.toString(new Date(), TIME_FORMAT, UTC_TIME_ZONE); if (length < TIME_BASED_RANDOM_MIN_LENGTH) length = TIME_BASED_RANDOM_MIN_LENGTH; return date + random(length - TIME_FORMAT.length()); } }
UnsafeIDGenerator { public static String timeBasedRandom(int length) { String date = DateValues.toString(new Date(), TIME_FORMAT, UTC_TIME_ZONE); if (length < TIME_BASED_RANDOM_MIN_LENGTH) length = TIME_BASED_RANDOM_MIN_LENGTH; return date + random(length - TIME_FORMAT.length()); } private  UnsafeIDGenerator(); }
UnsafeIDGenerator { public static String timeBasedRandom(int length) { String date = DateValues.toString(new Date(), TIME_FORMAT, UTC_TIME_ZONE); if (length < TIME_BASED_RANDOM_MIN_LENGTH) length = TIME_BASED_RANDOM_MIN_LENGTH; return date + random(length - TIME_FORMAT.length()); } private  UnsafeIDGenerator(); static String random(int length); static String timeBasedRandom(int length); }
UnsafeIDGenerator { public static String timeBasedRandom(int length) { String date = DateValues.toString(new Date(), TIME_FORMAT, UTC_TIME_ZONE); if (length < TIME_BASED_RANDOM_MIN_LENGTH) length = TIME_BASED_RANDOM_MIN_LENGTH; return date + random(length - TIME_FORMAT.length()); } private  UnsafeIDGenerator(); static String random(int length); static String timeBasedRandom(int length); static final int TIME_BASED_RANDOM_MIN_LENGTH; }