Java ID Value Create generateUniqueId()

Here you can find the source of generateUniqueId()

Description

generate Unique Id

License

Open Source License

Declaration

public static String generateUniqueId() 

Method Source Code

//package com.java2s;
/*/*  w  w  w.jav a  2s.c o m*/
 * DBeaver - Universal Database Manager
 * Copyright (C) 2010-2016 Serge Rieder (serge@jkiss.org)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License (version 2)
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

public class Main {
    private static java.util.Random secureRand;

    public static String generateUniqueId() {
        long curTime = System.currentTimeMillis();
        int random = secureRand.nextInt();
        if (random < 0) {
            random = -random;
        }

        return Long.toString(curTime, Character.MAX_RADIX)
                + Integer.toString(random, Character.MAX_RADIX);
    }
}

Related

  1. generateId(String salt)
  2. generateSalt()
  3. generateSalt()
  4. generateSalt()
  5. generateUniqueId()
  6. generateUniqueIdentity()
  7. generateUniqueName(String kind)
  8. generateUniqueString(int maxLength)
  9. toId(String id)