网站首页> 博客> Java随机生成订单表号,当前时间+随机五位数

Java随机生成订单表号,当前时间+随机五位数

好文 2807
格式化记忆
收藏

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  } }


  • 没有任何评论
个评论
格式化记忆

格式化记忆 (铂金)

95216金币 (273)粉丝 (31)源码

一切皆有可能!!!

 

加入微信群,不定期分享源码和经验
签到活跃榜 连续签到送额外金币
最新博客
校园跑腿系统外卖系统软件平台大学生创业平台搭建 460
壹脉销客智能名片CRM系统小程序可二开源码交付部署 447
为啥没搞了 649
Nginx 的 5 大应用场景,太实用了! 929
CentOS 8-stream 安装Postgresql 详细教程 1089
JAVA智慧校园管理系统小程序源码 电子班牌 Sass 模式 1050
Java智慧校园系统源码 智慧校园源码 智慧学校源码 智慧校园管理系统源码 小程序+电子班牌 797
Java智慧校园系统源码 智慧校园源码 智慧学校源码 智慧校园管理系统源码 小程序+电子班牌 777
致远OA权限 1270
发博客会有金币吗 811