Monday, 18 October 2010

How to use UUID?

How to use UUID?



















In java:


First, we have to import the library:

import java.util.UUID;

Finally, we generate a random UUID.

String newId = UUID.randomUUID().toString();

Easy? Yes, a lot.

2 comments:

vijayasankar said...

I want generate unique ID just like auto increment in java . So previously i used current nano seconds but i end up with clash since two data comes with in same nano seconds ..

I also dont able to increment the int value since once i shutdown the product and restart the memory lost and again i end up with clash .

Does UUID solves the above problems

Dante said...

hey ! I've been trying to read up on the matter from the Java API, but how do you get the following to 'work'?
0xFFFFFFFF00000000 time_low ?

its in the part about the different output formats for variant 2 UUID's.