Borrow the explanation of Baidu Encyclopedia to see what the UUID is.
Unique Identifier),这 是一个软件建构的标准,也是被开源软件基金会 (Open Software Foundation, OSF) 的组织应用在分布式计算环境 (Distributed Computing Environment, DCE) 领域的重要部分。
It can be understood as a string that is unique in the current time and space. Usually used on an activation code or an ID.
For example, the user uses the mailbox to register, but how to determine whether your mailbox is real, then you can send a user to register the mailbox sent an activation link, the link contains the activation code. Just like the one shown in the next section. The parameters given in the following code are the randomly generated UUID.
OK, now it's time to create a bunch of UUID.
public static void main(String[] args) { System.out.println("格式前的UUID : " + UUID.randomUUID().toString()); }
The results show:
格式前的UUID : 19eb68ee-5abe-42ce-9adb-57aad8ea59dd
It is clear that the UUID here is somewhat different from the code in the above connection. The difference in the resulting UUID is -
separated, but what we need is not -
separated. Then it needs to be dealt with.
The following shows the treated UUID and encapsulates it. Provides a public
method for external use.
Package cc.ccoder.mail.utils;Import Java.util.UUID;/** * * @ Author: Chencong * @ project: Mail--cc.ccoder.mail.utils * @ time: June 7, 2017 pm 7:05:14 * @TODO: Generate random string of tool class UUID */public class uuidutils {public static String getuuid () {return Uuid.randomuuid (). toString (). replace (public static void main (string[] args) {System.out.println (" UUID before format: "+ Uuid.randomuuid (). ToString ()); System.out.println ( "formatted UUID:" + Getuuid ())}}
Output Result:
68dcb13d-02ec-4233-b65a-6698830e0b51格式化后的UUID :d39b37b98606404cad9077ae29884330
This is a two-line UUID that is generated two times instead of operating on the same UUID, so it is not the same. The UUID that is processed is actually processing the resulting UUID string, which will be -
replaced with a null character.
Is it very simple, this blog is here .....
Java Tools Class--uuidutils