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

org.simpleflatmapper.util.UUIDHelper Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 9.0.2
Show 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());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy