zoukankan      html  css  js  c++  java
  • NumberUtils (idUtils ) 带时分秒

    public class NumberUtils {
        
        /**
         * @param prefix+yyyyMMddHHmmssSSS+2random
         * @return
         */
        public  static String  generateNumber(String prefix) {
            LocalDateTime ldt = LocalDateTime.now();
            DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
            //to the millisecond
            String milliSecond = ldt.format(dtf);
            prefix+=milliSecond;
            /*Not use the random as current data growth */
            String rondomtail="";
            Random random=new Random();
            for(int i=0;i<2;i++){
                rondomtail+=random.nextInt(10);
            }
            //    2020 06 05 14 25   01947 25
            return prefix+rondomtail;
        }
        
        
        /**
         * @param yyyyMMddHHmmssSSS+2random
         * @return
         */
        public  static String  genNO() {
            LocalDateTime ldt = LocalDateTime.now();
            DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
            //to the millisecond
            String milliSecond = ldt.format(dtf);
            /*Not use the random as current data growth */
            String rondomtail="";
            Random random=new Random();
            for(int i=0;i<2;i++){
                rondomtail+=random.nextInt(10);
            }
            //    2020 06 05 14 25   01947 25
            return milliSecond+rondomtail;
        }
        
        
        /**
         * 唯一值  uui + 3 random
         */
        public static String genUUID() 
        {
             String uuid = UUID.randomUUID().toString().replaceAll("-", "");
              /*Not use the random as current data growth */
                String rondomtail="";
                Random random=new Random();
                for(int i=0;i<3;i++){
                    rondomtail+=random.nextInt(10);
                }
            return uuid+rondomtail;
        }
    
        
  • 相关阅读:
    python生成试题库和界面 (python generate test database and layout)
    python生成数据库(python generate database)
    Go语言基础之流程控制
    Go语言基础之运算符
    Go语言基础之变量和常量
    VS Code配置Go语言开发环境
    Linux安装教程|详细
    安装Go语言及搭建Go语言开发环境
    Go语言
    Django2.0路由匹配path的用法
  • 原文地址:https://www.cnblogs.com/lshan/p/14120538.html
Copyright © 2011-2022 走看看