Java Tools Class--uuidutils

Source: Internet
Author: User
Tags uuid

Borrow the explanation of Baidu Encyclopedia to see what the UUID is.

Unique Identifier),这 是一个软件建构的标准,也是被开源软件基金会 (Open Software Foundation, OSF) 的组织应用在分布式计算环境 (Distributed Computing Environment, DCE) 领域的重要部分。
    • 1

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
    • 1
    • 2
    • 3

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.