{"id":1515,"date":"2012-01-18T18:55:24","date_gmt":"2012-01-19T01:55:24","guid":{"rendered":"http:\/\/juixe.com\/techknow\/?p=1515"},"modified":"2012-01-18T18:55:24","modified_gmt":"2012-01-19T01:55:24","slug":"create-universally-unique-id-in-java","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2012\/01\/18\/create-universally-unique-id-in-java\/","title":{"rendered":"Create Universally Unique ID in Java"},"content":{"rendered":"<p>For the longest time I&#8217;ve used java.rmi.server.UID to create a unique ID in a application.  We enhanced the UID class to fit our needs and to format the ID to the standard format but unfortunately we found that within a process, we were generating duplicate IDs if we created more than a certain amount.  It didn&#8217;t take much to remedy the problem since Java introduced java.util.UUID in Java 1.5.<\/p>\n<p>To create a universally unique ID in Java 1.5 or greater just call the static randomUUID method on the UUID class.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nUUID.randomUUID().toString()\r\n<\/pre>\n<p>UUID has a wider range of possible values that I&#8217;m not concern of duplicate values or collisions for my application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For the longest time I&#8217;ve used java.rmi.server.UID to create a unique ID in a application. We enhanced the UID class to fit our needs and to format the ID to the standard format but unfortunately we found that within a process, we were generating duplicate IDs if we created more than a certain amount. It [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[15,3],"tags":[653,656,802,657,445,655,654],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-or","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/1515"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=1515"}],"version-history":[{"count":1,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/1515\/revisions"}],"predecessor-version":[{"id":1516,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/1515\/revisions\/1516"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=1515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=1515"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=1515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}