Java UUID Generator (JUG), uuidjug

Source: Internet
Author: User

Java UUID Generator (JUG), uuidjug

UG is a Java-only UUID generator.

UUID refers to the number generated on a machine, which ensures that all machines in the same time and space are unique. Generally, the platform provides APIs for UUID generation. UUID is calculated according to the standards set by the Open Software Foundation (OSF), and uses Ethernet Card addresses, nanoseconds, chip ID codes, and many possible numbers. The combination of the following parts: the current date and time (the first part of UUID is related to the time. If you generate a UUID in seconds, the first part is different and the rest are the same), the clock sequence, and the globally unique IEEE machine identification number (if there is a network card, it is obtained from the network card, and no network card is obtained in other ways ), the unique defect of UUID is that the generated result string is long. The most common UUID standard is Microsoft's GUID (Globals Unique Identifiers ).


The project home page: http://jug.safehaus.org/


What is UUID? How does one generate UUID in Java?

GUID is a 128-bit long number, which is generally expressed in hexadecimal notation. The core idea of an algorithm is to combine the machine's Nic, local time, and a random number to generate a GUID. Theoretically, if a machine generates 10000000 guids per second, it can ensure (in probability) that there will be no duplicates in 3240.
UUID is a new class in 1.5. in java. util, it can generate a globally unique ID.
Import java. util. UUID;
Public class Test {
Public static void main (String [] args ){
UUID uuid = UUID. randomUUID ();
System. out. println (uuid );
}
}

What is the uuid in java? How does one execute a method to return a non-repeated string or number each time?

String id = UUID. randomUUID (). toString (). replace ("-","");
A 128-bit long number, usually expressed in hexadecimal notation

Generate a 32-bit string, which is generally used as the primary key of the table.

UUID. randomUUID (). toString (); format:

550E8400-E29B-11D4-A716-446655440000

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.