生成商户订单号/退款单号

  public static String getRandomStringByLength(int length) {
        String base = "0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }


    /**
     * @function 生成商户订单号/退款单号
     * @date 2015-12-17
     * @return String
     */
    public static String getOrderNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        Date date = new Date();
        return sdf.format(date) + getRandomStringByLength(4);
    }

  

转载于:https://www.cnblogs.com/xrhou12326/p/6623451.html

你可能感兴趣的:(生成商户订单号/退款单号)