自动生成ID


public class IdUtil {
    /**
     *
     * @return 返回时间id,类似于20191217195622
     */
    public static String timeId(){
        Date date=new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        return dateFormat.format(date);
    }

    /**
     *
     * @return 返回带-的id
     */
    public static String _UID(){
        String id= UUID.randomUUID().toString();
        return id;
    }
    /**
     *
     * @return 返回不带-的id
     */
    public static String UID(){
        String id= UUID.randomUUID().toString().replaceAll("-","");
        return id;
    }
    /**
     * 获取tLongTime 当前时间的毫秒数
     * @return
     */
    public static String  getLongTimeId(){
        long  longValue =System.currentTimeMillis();
        return  String.valueOf(longValue);

    }

    /**
     * 判断字符串是否为空
     * @param str
     * @return
     */
    public static String  nullutil(String str){
        if(str==null){
            return str="0";
        }
        return str;
    }

}