package com.vci.client.uif.engine.client.compare.tools;
|
|
import java.text.SimpleDateFormat;
|
import java.util.Calendar;
|
import java.util.Date;
|
|
/**
|
* 常用工具类
|
* @author VCI-STGK006
|
*
|
*/
|
public class CompareTools {
|
|
/**
|
* 数字类型是否一致校验
|
* @param num1 数字1
|
* @param num2 数字2
|
* @return 如果两个数字都为空返回true
|
*/
|
public static boolean validateNumber(String num1, String num2){
|
if(num1 == null) {
|
num1 = "";
|
}
|
if(num2 == null) {
|
num2 = "";
|
}
|
boolean temp = true;
|
if(!num2.equals(num1)){
|
//如果不一致还需判断是否是数字格式不一致导致
|
if(!num1.equals("") && !num2.equals("")){
|
try{
|
double dNum1 = Double.parseDouble(num1);
|
double dNum2 = Double.parseDouble(num2);
|
if(dNum1 != dNum2){
|
temp = false;
|
}
|
} catch(Exception e){
|
temp = false;
|
}
|
} else {
|
return false;
|
}
|
}
|
return temp;
|
}
|
|
/**
|
* 得到去空字符串
|
* @param str
|
* @return
|
*/
|
public static String getString(String str) {
|
if(str == null) {
|
return "";
|
}
|
return str.trim();
|
}
|
|
/**
|
* 获得当前时间字符串
|
* @return
|
*/
|
public static String getSysDateTs() {
|
Date now = Calendar.getInstance().getTime();
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
String nowStr = sdf.format(now);
|
return nowStr + ".00";
|
}
|
|
/**
|
* 获得当前时间字符串
|
* @return
|
*/
|
public static String getSysDate() {
|
Date now = Calendar.getInstance().getTime();
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
String nowStr = sdf.format(now);
|
return nowStr;
|
}
|
}
|