Cato,
Here is code that I tried out for generating a user id using the user name
I have to pass a string and it returns a 8 digit alpha numeric
Hope it helps,

Anil
----------------------------------------------------------------------------

  public static String getCode(String text){
     String code = "";


        text = text.trim();
        if(text.length()<1){
            return null;
        }
        text = text.toUpperCase();
        if(random==null){
            random = new java.util.Random();
        }
        String code_temp = "";
         int no_of_chars = 3 ; //not of chars from text

        for(int i=0;i<no_of_chars;i++){
          code_temp =
String.valueOf(text.charAt(random.nextInt(text.length())));
          if(code_temp.equals(" ")){
                i--;
           }else{
                code = code + code_temp;
           }
        }

        code = code + java.lang.String.valueOf(random.nextInt(10000));
        java.util.Date date = new java.util.Date();
        code = code + java.lang.String.valueOf(date.getDate());
    }catch(Exception e){
        return null;
    }
        return code;

    }





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to