Java UUID Create uuidFromString(String s)

Here you can find the source of uuidFromString(String s)

Description

uuid From String

License

Open Source License

Declaration

public static UUID uuidFromString(String s) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static UUID uuidFromString(String s) {
        if (s.contains("-")) {
            return UUID.fromString(s);
        } else {//from   w w  w . j  a  v  a  2  s.  c  om
            return UUID
                    .fromString(s
                            .replaceFirst(
                                    "([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)",
                                    "$1-$2-$3-$4-$5"));
        }
    }
}

Related

  1. sizeOfUUID(UUID uuid)
  2. uuid()
  3. uuid()
  4. uuid()
  5. uuid()
  6. uuidWithTime()