org.simpleflatmapper.util.UUIDHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-util Show documentation
Show all versions of sfm-util Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
The newest version!
package org.simpleflatmapper.util;
import java.nio.ByteBuffer;
import java.util.UUID;
public class UUIDHelper {
public static byte[] toBytes(UUID uuid) {
byte[] bytes = new byte[16];
ByteBuffer
.wrap(bytes)
.putLong(uuid.getMostSignificantBits())
.putLong(uuid.getLeastSignificantBits());
return bytes;
}
public static UUID fromBytes(byte[] bytes) {
final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
return new UUID(byteBuffer.getLong(), byteBuffer.getLong());
}
}