Skip to content

Instantly share code, notes, and snippets.

@edanuff
Created December 17, 2010 23:17
Show Gist options
  • Save edanuff/745889 to your computer and use it in GitHub Desktop.
Save edanuff/745889 to your computer and use it in GitHub Desktop.
UUIDUtils
import java.nio.ByteBuffer;
import java.util.UUID;
public class UUIDUtils {
public static UUID uuid(byte[] uuid) {
return uuid(uuid, 0);
}
public static UUID uuid(byte[] uuid, int offset) {
ByteBuffer bb = ByteBuffer.wrap(uuid, offset, 16);
return new UUID(bb.getLong(), bb.getLong());
}
public static UUID uuid(ByteBuffer bb) {
bb = bb.slice();
return new UUID(bb.getLong(), bb.getLong());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment