生成纳秒级别的订单号
package com.example.core.mydemo.orderno; import java.util.Random; public class ODDGenerator { /** * 生成纳秒级别的订单号 * * @return */ public static String getOrderNo() { Long nanoTime = System.nanoTime(); Random ra = new Random(); String orderNum = nanoTime + ra.nextInt(1000) + ""; return orderNum; } /** * orderNo=18047864311077 * @param args */ public static void main(String[] args) { System.out.println("orderNo=" + getOrderNo()); } }
标签:String,纳秒,Random,订单号,nanoTime,级别,public From: https://www.cnblogs.com/oktokeep/p/17223295.html