1 29 30 package nextapp.echo2.app.util; 31 32 35 public class Uid { 36 37 private static final String machineIdString = Integer.toHexString(new Object ().hashCode()); 38 private static int globalCount = 0; 39 40 private final int count = ++globalCount; 41 private final long time = System.currentTimeMillis(); 42 43 46 public static final String generateUidString() { 47 String idString = new Uid().toString(); 48 return idString; 49 } 50 51 54 private Uid() { 55 super(); 56 } 57 58 61 public String toString() { 62 String timeString = Long.toHexString(time); 63 String countString = Integer.toHexString(count); 64 65 return machineIdString + "_" + timeString + "_" + countString; 66 } 67 } 68 | Popular Tags |