Java UUID Create generateId()

Here you can find the source of generateId()

Description

generate Id

Declaration

public static String generateId() 

Method Source Code


//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class Main {
    public static String generateId() {
        Date date = new Date();
        //      SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-hhmmss");

        String formattedDate = sdf.format(date);

        Random r = new Random();

        return formattedDate + "-" + r.nextInt(10000);
    }//from  ww  w  . j av a2s .  c  o m
}

Related

  1. generateEmailPrefix()
  2. generateFakedDeviceTokenString()
  3. generateFileName(String path)
  4. generateGUID()
  5. generateGUID()
  6. generateID()
  7. generateId()
  8. generateRandomMap(int count)
  9. generateRandomName()