Generate random String From Time - Java java.lang

Java examples for java.lang:String Random

Description

Generate random String From Time

Demo Code


//package com.java2s;

import java.util.Date;

public class Main {
    public static void main(String[] argv) {
        System.out.println(randomStringFromTime());
    }/*from   ww w  .j a  v  a 2  s  .  c  o m*/

    public static String randomStringFromTime() {

        final String nowTicks = Long.toString(new Date().getTime());

        final StringBuilder sb = new StringBuilder();
        for (final Character ch : nowTicks.toCharArray()) {
            final int offset = Integer.parseInt(ch.toString());
            final char chr = (char) (65 + offset);

            sb.append(chr);
        }
        return sb.toString().toLowerCase();
    }
}

Related Tutorials