package com.zjty.inspect.utils;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.Stack;

/**
 * @author Mcj
 * @date 2020-03-05 19:20
 */

public class RandomUtil {
    public synchronized static String getRandom()
    {
        String digths = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        int base = digths.length();
        long now = System.currentTimeMillis();
        try {Thread.sleep(1);} catch (InterruptedException e) {e.printStackTrace();}
        StringBuffer str = new StringBuffer("");
        Stack<Character> s = new Stack<Character>();
        while(now != 0){
            s.push(digths.charAt((int)(now%base)));
            now/=base;
        }
        while(!s.isEmpty()){
            str.append(s.pop());
        }
        StringBuilder stringBuilder = new StringBuilder();
        LocalDateTime date = LocalDateTime.now();
        String[] split = UUIDUtil.getUUID().split("-");
        stringBuilder.append(date.getYear())
                .append(date.getMonth())
                .append(date.getDayOfMonth())
                .append(date.getHour() )
                .append(date.getMinute())
                .append(date.getSecond())
                .append(split[0]);
        return stringBuilder.toString();
    }
}
