简体   繁体   中英

Unique ID Code in Java

Hi I want you guys suggestion.

I want to create a 15 length key code form current time stamp. Code should contain small and capital characters with digits. Anyone can suggest how I can create a 15 length unique code from current time stamp? Using Java in servlet side.

Given your constraints, I'd probably create a GUID , append or prepend a timestamp, and transform it into the 15-letters format. GUIDs are 32 hexadecimal digits and so have 32^16 (1.20892582x10 24 ) possible values (although not all of them are used). 15 characters with digits or upper or lower case English letters (so, 62 possible values per digit) gives you 15^62 (8.272905461x10 72 ) — plenty of room. If you were okay adding + and / to your list of possible characters, you could use Base64 encoding rather than doing it yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM