网站首页> 博客> Java随机生成订单表号,当前时间+随机五位数
Java随机生成订单表号,当前时间+随机五位数
package cn.gov.csrc.util;
import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random;
public class RandomUtil {
/** * 生成随机文件名:当前年月日时分秒+五位随机数 * * @return */ public static String getRandomFileName() {
SimpleDateFormat simpleDateFormat;
simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String str = simpleDateFormat.format(date);
Random random = new Random();
int rannum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000;// 获取5位随机数
return rannum + str;// 当前时间 }
public static void main(String[] args) {
String fileName = RandomUtil.getRandomFileName();
System.out.println(fileName);//8835920140307 } }
- 加入微信群,不定期分享源码和经验

- 签到活跃榜 连续签到送额外金币
- 最新博客
- 校园跑腿系统外卖系统软件平台大学生创业平台搭建 859
- 壹脉销客智能名片CRM系统小程序可二开源码交付部署 883
- 为啥没搞了 1353
- Nginx 的 5 大应用场景,太实用了! 1540
- CentOS 8-stream 安装Postgresql 详细教程 1838
- JAVA智慧校园管理系统小程序源码 电子班牌 Sass 模式 1411
- Java智慧校园系统源码 智慧校园源码 智慧学校源码 智慧校园管理系统源码 小程序+电子班牌 1188
- Java智慧校园系统源码 智慧校园源码 智慧学校源码 智慧校园管理系统源码 小程序+电子班牌 1160
- 致远OA权限 1980
- 发博客会有金币吗 1217