public class Uid { private static final String machineIdString = Integer.toHexString(new Object().hashCode()); private static final AtomicInteger globalCount = new AtomicInteger(0); private final int count = globalCount.incrementAndGet(); private final long time = System.currentTimeMillis(); /** * Generates a new identifier. */ private Uid() { super(); } /** * Generates a new identifier String. */ public static String generateUidString() { String idString = new Uid().toString(); return idString; } /** * @see Object#toString() */ public String toString() { String timeString = Long.toHexString(time); String countString = Integer.toHexString(count); return machineIdString + "_" + timeString + "_" + countString; }}