• Post Reply Bookmark Topic Watch Topic
  • New Topic

UUID from String  RSS feed

 
Ranch Hand
Posts: 1906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there any way of generating UUID from specific String? API has one method- fromString("") but successive UUIDs generated from it don't seem to contain the long number.
Example-

Am I missing something?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arjun Shastry wrote:Hi,
Is there any way of generating UUID from specific String? API has one method- fromString("") but successive UUIDs generated from it don't seem to contain the long number.
Example-

Am I missing something?


The successive IDs generated are not "from" that original one. The randomUUID() method is static and therefore has no relation to any instance. (And it wouldn't be very random if such a relation existed.)
 
Arjun Shastry
Ranch Hand
Posts: 1906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
But how to generate UUId from given String ?
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arjun Shastry wrote:Thanks.
But how to generate UUId from given String ?

I don't understand your problem. What's wrong with the UUID.fromString method ?
 
Arjun Shastry
Ranch Hand
Posts: 1906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to generate UUID which contains constant Substring? For example following strings contain string-ABCDEFGHYZ

Is there anyway to produce such UUIDs?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arjun Shastry wrote:Is there any way to generate UUID which contains constant Substring? For example following strings contain string-ABCDEFGHYZ

Is there anyway to produce such UUIDs?


Yes. The way to do it is to clearly define your requirements as to what the rest of the UUID will look like given the substring(s) you provide, and then write code to implement those requirements.

(Being careful of course to make sure that the String follows the rules of UUIDs in general, if you plan to make it available anywhere outside your app, or to use it with the UUID class.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!