Java tutorial
//package com.java2s; import java.util.concurrent.atomic.AtomicInteger; public class Main { private final static String str62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; private static final AtomicInteger ATOM_INT = new AtomicInteger(0); public final static String create15() { StringBuilder sb = new StringBuilder(15); sb.append(Long.toHexString(System.currentTimeMillis())); String str = longTo36(ATOM_INT.incrementAndGet()); if (str.length() == 1) { sb.append("000").append(str); } else if (str.length() == 2) { sb.append("00").append(str); } else if (str.length() == 3) { sb.append("0").append(str); } else { sb.append(str); } return sb.toString(); } public static final String longTo36(long num) { return ten2Any(num, 36); } private static final String ten2Any(long num, int base) { StringBuilder sb = new StringBuilder(7); while (num != 0) { sb.append(str62.charAt((int) (num % base))); num /= base; } return sb.reverse().toString(); } }