package vn.azteam.tpf.web.rest.util;

import java.util.UUID;

public final class RandomStringUtil {

    private static final long LIMIT = 10000000000L;
    private static long last = 0;

    public static String generateRandomStringFromUUID(int stringLength) {
        String qrCode = UUID
            .randomUUID()
            .toString()
            .replace("-", "")
            .substring(0, stringLength)
            .toUpperCase();
        return qrCode;
    }

    public static long getDigitCodeDetail() {
        // 10 digits.
        long id = System.currentTimeMillis() % LIMIT;
        if (id <= last) {
            id = (last + 1) % LIMIT;
        }
        return last = id;
    }

}
