I have a task to generate a unique string, the first thought which came to my mind was to use Java's UUID generator with additional improvements. And so my way of generating a random string looks something like this
public static String generateRandomString() {
return "TEST" +
DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSSSSS")
.format(LocalDateTime.now()) + UUID.randomUUID()
.toString().replace("-", "");
}
would this method generating a random string would be sufficient to achieve uniqueness having in mind that I need to generate 10 000 000 of them on a daily basis for the next 20 years. Also, this piece of code will be spinning on different JVM and potentially on different servers.