package com.iailab.module.data.video.hikvision.utils;
|
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
|
public class CommonUtils {
|
/**
|
*<p>获取当前日期<p>
|
*<p>格式yyyyMMdd<p>
|
*/
|
public static String getCurrDate(){
|
Date date=new Date();
|
SimpleDateFormat df1 = new SimpleDateFormat("yyyyMMdd");
|
String tDate = df1.format(date);
|
return tDate;
|
}
|
|
/**
|
*<p>获取当前时间<p>
|
*<p>格式yyyyMMddHHmmss<p>
|
*/
|
public static String getCurrDate2(){
|
Date date=new Date();
|
SimpleDateFormat df1 = new SimpleDateFormat("yyyyMMddHHmmss");
|
String tDate = df1.format(date);
|
return tDate;
|
}
|
|
/**
|
*<p>获取当前时间<p>
|
*<p>格式yyyy-MM-dd HH:mm:ss<p>
|
*/
|
public static String getCurrDate3(){
|
Date date=new Date();
|
SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
String tDate = df1.format(date);
|
return tDate;
|
}
|
|
/**
|
* 由年月日时分秒+3位随机数
|
* 生成流水号
|
* @return
|
*/
|
public static Long Getnum(){
|
String t = getCurrDate2();
|
int x=(int)(Math.random()*900)+100;
|
String serial = t + x;
|
Long num = new Long(serial);
|
return num;
|
}
|
|
//主方法测试
|
public static void main(String[] args) {
|
System.out.println(Getnum());
|
}
|
}
|