前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >生成唯一订单号 工具类

生成唯一订单号 工具类

作者头像
用户7741497
发布2022-08-04 17:29:46
8280
发布2022-08-04 17:29:46
举报
文章被收录于专栏:hml_知识记录hml_知识记录

package com.jsy.basic.util.utils;

import java.text.SimpleDateFormat;

import java.util.Date;

/**

* @program: pay

* @description: 生成唯一订单号

* @author: Hu

* @create: 2021-01-22 10:19

**/

public class OrderNoUtil {

/**

* @Description: 支付下单订单号

* @author: Hu

* @since: 2021/2/23 17:52

* @Param:

* @return:

*/

public static String getOrder() {

SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String s=sdfTime.format(new Date().getTime()).replaceAll("[[\\s-:punct:]]", "");

int s1=(int) (Math.random() * 999999999);

int s2=(int) (Math.random() * 9);

return s + s1 + s2;

}

public static void main(String[] args) {

System.out.println(getOrder());

System.out.println(new Date().getTime());

}

/**

* @Description: 企业付款订单号

* @author: Hu

* @since: 2021/2/23 17:52

* @Param:

* @return:

*/

public static String txOrder() {

SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String s=sdfTime.format(new Date().getTime()).replaceAll("[[\\s-:punct:]]", "");

s+=(char) (Math.random() * 26 + 'a');

s+=(int) (Math.random() * 99);

s+=(char) (Math.random() * 26 + 'A');

s+=(int) (Math.random() * 9);

s+=(char) (Math.random() * 26 + 'a');

s+=(char) (Math.random() * 26 + 'A');

s+=(int) (Math.random() * 9);

s+=(char) (Math.random() * 26 + 'a');

s+=(char) (Math.random() * 26 + 'A');

return s;

}

}

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档