title: Convert ByteArray to UUID java
body: <p>Question is How do I convert ByteArray to GUID. </p>
  
  <p>Previously I converted my guid to byte array, and after some transaction I need my guid back from byte array. How do I do that. Although irrelevant but conversion from Guid to byte[] is as below</p>
  
  <pre><code>    public static byte[] getByteArrayFromGuid(String str)
      {
          UUID uuid = UUID.fromString(str);
          ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
          bb.putLong(uuid.getMostSignificantBits());
          bb.putLong(uuid.getLeastSignificantBits());
  
          return bb.array();
      }
  </code></pre>
  
  <p>but how do I convert it back??</p>
  
  <p>I tried this method but its not returning me same value</p>
  
  <pre><code>    public static String getGuidFromByteArray(byte[] bytes)
      {
          UUID uuid = UUID.nameUUIDFromBytes(bytes);
          return uuid.toString();
      }
  </code></pre>
  
  <p>Any help will be appreciated. </p>