출처: http://november11tech.tistory.com/88 [Mr.november11] int to hex :: 사월은 봄이다.

흠, Integer에 함수가 있었다.

private String seqIdtoHex(){

int seq = (int) (Math.random() * (65535 - 1 + 1)) + 1;

String result = Integer.toHexString(seq);

return result;

}




 




여기 보면 random으로 돌리는데, random으로 뽑으려는 수가 Min에서 Max 사이의 수를 뽑기 위함이다.


hex로 변환하려면, Integer.toHexString 으로 하면 String 형식으로 반환해준다.



'개발 > JAVA' 카테고리의 다른 글

string.format 에서 % 표현법  (0) 2018.02.10
split -> Array List로 집어 넣기  (0) 2018.02.10
String null 체크  (0) 2018.02.10
Unix Time, Local Time  (0) 2018.02.10
Session attribute 뽑아내기  (0) 2018.02.10

+ Recent posts