介绍
这里是小编成长之路的历程,也是小编的学习之路。希望和各位大佬们一起成长!
以下为小编最喜欢的两句话:
要有最朴素的生活和最遥远的梦想,即使明天天寒地冻,山高水远,路远马亡。
一个人为什么要努力? 我见过最好的答案就是:因为我喜欢的东西都很贵,我想去的地方都很远,我爱的人超完美。因此,小编想说:共勉!
代码:
package com.lyn.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class AutoOrder {
/**
* 获取现在时间
* @return返回字符串格式yyyyMMddHHmmss
*/
public static String getStringDate() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("YYMMddHHmmss");
String dateString = formatter.format(currentTime);
// System.out.println("TIME:::"+dateString);
return dateString;
}
public static String getStringDate1() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("mmss");
String dateString = formatter.format(currentTime);
// System.out.println("TIME:::"+dateString);
return dateString;
}
/**
* 固定资产编号,由年月日时分秒+3位随机数
* 生成流水号
* @return
*/
public static String assetNumber(){
String t = getStringDate1();
int x=(int)(Math.random()*90)+10;
String serial = t + x;
return serial;
}
/**
* 由年月日时分秒+3位随机数
* 生成流水号
* @return
*/
public static String Getnum(){
String t = getStringDate();
int x=(int)(Math.random()*90)+10;
String serial = t + x;
return serial;
}
/**
* 由年月日时分秒+3位随机数
* 生成流水号
* @return
*/
public static String Getnum1(){
String t = getStringDate();
int x=(int)(Math.random()*9);
String serial = t + x;
return serial;
}
public static String getTwo() {
Random rad = new Random();
String result = rad.nextInt(100) + "";
if (result.length() == 1) {
result = "0" + result;
}
return result;
}
public static String GetSystemserialnumber() {
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
String seconds = new SimpleDateFormat("HHmmss").format(new Date());
return "EX" + date + getTwo() + "00" + seconds + getTwo();
}
//主方法测试
public static void main(String[] args) {
String m= GetSystemserialnumber();
System.out.println(m);
}
}
运行的结果
以上就是小编所使用到的代码,希望能够帮到大家,感谢各位大佬的观看!!!