Generate globally unique identities using UUID __string

Source: Internet
Author: User
Tags uuid

You need to generate a unique string, such as a build application identification, that can be implemented directly with the Java.util.UUID class.

The UUID (universally unique Identifier) Globally unique identifier, which is the number generated on a single machine, guarantees that all machines in the same space-time are unique.

The UUID consists of a combination of the following parts:

1, the current date and time , the first part of the UUID is related to time, and if you generate a UUID after a few seconds after generating an UUID, the first part is different and the rest is the same.

2, clock sequence

3, the globally unique IEEE Machine identification number (if there is a network card, obtained from the network card, no network card in other ways to obtain).

The only drawback to the UUID is that the resulting string will be longer.

You can get a unique string by calling the following methods.

UUID uuid = Uuid.randomuuid (); String s = Uuid.randomuuid (). toString ();

The UUID consists of a 16-digit number, produced in the form of a string such as: 9291d71a-0354-4d8e-acd8-64f7393c64ae.

If the identity is applied, replace the '-' alternative to null by using a string method, and the string form, such as 9291d71a03544d8eacd864f7393c64ae, can be obtained.

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: info-contact@alibabacloud.com 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.