生成19位long型唯一数字id

 /**
     * 生成19位long型唯一数字id
     * @return
     */
    public static long GetLong19UUID() {
        //  String nanoRandom = System.nanoTime() + "" + random.nextInt(99999);
        SimpleDateFormat sdf =new SimpleDateFormat("YYMMdd");
        String dayTime=sdf.format(new Date());
        int hashcode= UUID.randomUUID().toString().hashCode();
        if(hashcode<0)
        {
            hashcode=-hashcode;
        }
        int i = (int)(Math.random()*900 + 100);
        String value = dayTime+String.format("%010d",hashcode)+ i;
        long l = Long.parseLong(value);
        return l;
    }

 

posted on 2023-03-03 08:40  五官一体即忢  阅读(456)  评论(0编辑  收藏  举报

导航