All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.apicatalog.uuid.Uuid Maven / Gradle / Ivy

The newest version!
package com.apicatalog.uuid;

import java.nio.ByteBuffer;
import java.util.UUID;

public class Uuid {

    public static byte[] toBytes(UUID uuid) {
        ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
        bb.putLong(uuid.getMostSignificantBits());
        bb.putLong(uuid.getLeastSignificantBits());
        return bb.array();
    }
    
    public static UUID of(byte[] bytes) {
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
        long high = byteBuffer.getLong();
        long low = byteBuffer.getLong();
        return new UUID(high, low);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy