Skip to content

Instantly share code, notes, and snippets.

@jeffypooo
Last active August 2, 2017 14:27
Show Gist options
  • Save jeffypooo/10922165432ec016a823e46c6eb382e6 to your computer and use it in GitHub Desktop.
Save jeffypooo/10922165432ec016a823e46c6eb382e6 to your computer and use it in GitHub Desktop.
/**
* Workaround for https://code.google.com/p/android/issues/detail?id=197341
*/
private UUID byteSwappedUuid(UUID toSwap) {
ByteBuffer buffer = ByteBuffer.allocate(16);
buffer
.putLong(toSwap.getLeastSignificantBits())
.putLong(toSwap.getMostSignificantBits());
buffer.rewind();
buffer.order(ByteOrder.LITTLE_ENDIAN);
return new UUID(buffer.getLong(), buffer.getLong());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment