Implementation method of generating GUID based on Java _java

Source: Internet
Author: User
Tags local time unique id uuid
A GUID is a 128-bit long number, typically represented by a 16 binary. The core idea of the algorithm is to combine the machine's network card, local time, and a random number to generate the GUID. Theoretically, if a machine produces 10 million GUIDs per second, it can be guaranteed (in the sense of probability) not to repeat for 3,240 years.
Copy Code code as follows:

Package com.cn.str;
Import Java.util.UUID;
/**
* Create GUID
* @author Administrator
*
*/
public class CreateGUID {

public static final String Generateguid () {
UUID uuid = Uuid.randomuuid ();
return uuid.tostring ();
}
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
System.out.println (Generateguid ());
}
}

The UUID is a new class in 1.5 that, under Java.util, can produce a supposedly globally unique ID

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.