UUID가 dash(-) 포함 36자리로 너무 길어서 짧은 UUID를 고민하다가 만들어본 코드
https://gist.github.com/LeeSanghoon/5811136
/**
* Generate short UUID (13 characters)
*
* @return short UUID
*/
public static String shortUUID() {
UUID uuid = UUID.randomUUID();
long l = ByteBuffer.wrap(uuid.toString().getBytes()).getLong();
return Long.toString(l, Character.MAX_RADIX);
}
'Java' 카테고리의 다른 글
| valueOf() 와 parseInt() (0) | 2013.03.09 |
|---|---|
| HttpURLConnection 사용시 http ~ https 간의 리다이렉션 처리 (0) | 2013.01.03 |
| Google Collections (0) | 2010.01.20 |