生成uuid

package com.neusoft.oss.utils;

import java.util.UUID;

/**

  • Created by yuanwai (lxdhzzj@gmail.com)

  • Create Time: 2015/6/9 14:50

  • Description: UUID生成器.
    */
    public class IdGen {

    public static String getUUID() {
    UUID uuid = UUID.randomUUID();
    String str = uuid.toString();
    String temp = str.substring(0, 8) + str.substring(9, 13) + str.substring(14, 18) + str.substring(19, 23) + str.substring(24);
    return temp;
    }
    public static String[] getUUID(int number) {
    if (number < 1) {
    return null;
    }
    String[] ss = new String[number];
    for (int i = 0; i < number; i++) {
    ss[i] = getUUID();
    }
    return ss;
    }

    public static void main(String[] args){

     System.out.println(IdGen.getUUID());
    

    }
    }

生成uuid

上一篇:如何写出让同事无法维护的代码?(转)


下一篇:谷歌验证码