Created
December 17, 2010 23:17
-
-
Save edanuff/745889 to your computer and use it in GitHub Desktop.
UUIDUtils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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