自動生成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;
    }

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM