Java UUID from uuidFromMsftBinary(byte[] uuidMsftBytes)

Here you can find the source of uuidFromMsftBinary(byte[] uuidMsftBytes)

Description

uuid From Msft Binary

License

Apache License

Declaration

public static UUID uuidFromMsftBinary(byte[] uuidMsftBytes) 

Method Source Code


//package com.java2s;
/*/*from   w  w  w .  j  av a  2s  .  c o m*/
Apache Licensed Code modified from:
        
 */

import java.nio.ByteBuffer;

import java.util.UUID;

public class Main {
    public static UUID uuidFromMsftBinary(byte[] uuidMsftBytes) {
        byte[] uuidJavaBytes = new byte[16];

        // Convert Big Indian to Little Indian
        uuidJavaBytes[0] = uuidMsftBytes[3];
        uuidJavaBytes[1] = uuidMsftBytes[2];
        uuidJavaBytes[2] = uuidMsftBytes[1];
        uuidJavaBytes[3] = uuidMsftBytes[0];
        uuidJavaBytes[4] = uuidMsftBytes[5];
        uuidJavaBytes[5] = uuidMsftBytes[4];
        uuidJavaBytes[6] = uuidMsftBytes[7];
        uuidJavaBytes[7] = uuidMsftBytes[6];

        uuidJavaBytes[8] = uuidMsftBytes[8];
        uuidJavaBytes[9] = uuidMsftBytes[9];
        uuidJavaBytes[10] = uuidMsftBytes[10];
        uuidJavaBytes[11] = uuidMsftBytes[11];
        uuidJavaBytes[12] = uuidMsftBytes[12];
        uuidJavaBytes[13] = uuidMsftBytes[13];
        uuidJavaBytes[14] = uuidMsftBytes[14];
        uuidJavaBytes[15] = uuidMsftBytes[15];

        return uuidFromThriftBinary(uuidJavaBytes);
    }

    public static UUID uuidFromThriftBinary(byte[] uuidThriftBytes) {
        ByteBuffer bb = ByteBuffer.wrap(uuidThriftBytes);

        return new UUID(bb.getLong(), bb.getLong());
    }
}

Related

  1. UUIDFromBytes(byte[] array)
  2. uuidFromBytes(byte[] b)
  3. uuidFromBytes(byte[] bytes)
  4. uuidFromThriftBinary(byte[] uuidThriftBytes)