java - Generating reproducible IDs with UUID? -
i'm using uuid.randomuuid().getleastsignificantbits(); generate unique ids. want generate same ids every time run application in order debug code. how can that?
edit: zim-zam created class solves problem.
public class idgenerator { private static random random = new random(1); public static long getid() { long id; byte[] array = new byte[16]; random.nextbytes(array); id = uuid.nameuuidfrombytes( array ).getleastsignificantbits(); return id; } }
you can use uuid.nameuuidfrombytes(byte[] bytes) byte[] bytes random or securerandom seeded
Comments
Post a Comment