package com.iailab.common.utils;
|
|
import java.math.BigDecimal;
|
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 BigDecimal getJSONValue(Object obj) {
|
if (obj == null) {
|
return null;
|
}
|
return new BigDecimal(obj.toString());
|
}
|
|
}
|