生成纳秒级别的订单号
生成纳秒级别的订单号
package com.example.core.mydemo.orderno; import java.util.Random; public class Test{ /** * 生成纳秒级别的订单号 * * @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()); } }