package com.base;
|
|
import java.io.IOException;
|
import java.io.PrintStream;
|
import java.text.DateFormat;
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
|
public class Com {
|
public static final int UploadData_ClientType_BS_CLI = 0;
|
public static final int UploadData_ClientType_CS_CLI = 1;
|
public static final int UploadData_ClientType_CS_SVR = 2;
|
public static final String DTF_YMDhms = "yyyy-MM-dd HH:mm:ss";
|
public static final String DTF_YMDhm = "yyyy-MM-dd HH:mm";
|
public static final String DTF_YMDh = "yyyy-MM-dd HH";
|
public static final String DTF_YMD = "yyyy-MM-dd";
|
public static final String DTFYMD = "yyyyMMdd";
|
public static final String DTF_hms = "HH:mm:ss";
|
final public static String DTF_YM = "yyyy_MM";
|
public static final String DTF_YMD_h_m_s = "yyyy-MM-dd+HH_mm_ss";
|
|
public static String getDateTimeFormat(Date dt, String format) {
|
DateFormat dtf = new SimpleDateFormat(format);
|
return dtf.format(dt);
|
}
|
|
public static Date getDateTimeFromStr(String dt, String format) {
|
DateFormat dtf = new SimpleDateFormat(format);
|
Date date = new Date();
|
try {
|
date = dtf.parse(dt);
|
} catch (ParseException e) {
|
e.printStackTrace();
|
}
|
|
return date;
|
}
|
|
public static String getNowTimeWithAt() {
|
return " @ " + getDateTimeFormat(new Date(), "yyyy-MM-dd HH:mm:ss");
|
}
|
|
public static boolean isIntegerNumber(String number) {
|
number = number.trim();
|
String intNumRegex = "\\-{0,1}\\d+";
|
if (number.matches(intNumRegex)) {
|
return true;
|
}
|
return false;
|
}
|
|
public static boolean isFloatPointNumber(String number) {
|
number = number.trim();
|
String intNumRegex = "\\-{0,1}\\d+";
|
String pointPrefix = "(\\-|\\+){0,1}\\d*\\.\\d+";
|
String pointSuffix = "(\\-|\\+){0,1}\\d+\\.";
|
if ((number.matches(intNumRegex)) || (number.matches(pointPrefix)) || (number.matches(pointSuffix))) {
|
return true;
|
}
|
return false;
|
}
|
|
public static boolean isValidDate(String str, String format) {
|
boolean convertSuccess = true;
|
try {
|
DateFormat dtf = new SimpleDateFormat(format);
|
dtf.parse(str);
|
} catch (ParseException e) {
|
convertSuccess = false;
|
}
|
return convertSuccess;
|
}
|
|
public static void setDateTime(Date ts) {
|
String osName = System.getProperty("os.name");
|
String cmd = "";
|
try {
|
if (osName.matches("^(?i)Windows.*$")) {
|
cmd = "cmd /c time " + getDateTimeFormat(ts, "HH:mm:ss");
|
Runtime.getRuntime().exec(cmd);
|
|
cmd = "cmd /c date " + getDateTimeFormat(ts, "yyyy-MM-dd");
|
Runtime.getRuntime().exec(cmd);
|
} else {
|
cmd = "date -s " + getDateTimeFormat(ts, "yyyyMMdd");
|
Runtime.getRuntime().exec(cmd);
|
|
cmd = "date -s " + getDateTimeFormat(ts, "HH:mm:ss");
|
Runtime.getRuntime().exec(cmd);
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
|
public static void getIPFromStr(String ipstr, byte[] ip) {
|
try {
|
for (int n = 0; n < 3; n++) {
|
int index = ipstr.indexOf('.');
|
if (index > 0) {
|
ip[n] = ((byte) Integer.parseInt(ipstr.substring(0, index)));
|
}
|
ipstr = ipstr.substring(index + 1);
|
}
|
ip[3] = ((byte) Integer.parseInt(ipstr));
|
} catch (Exception e) {
|
System.out.println(e.getMessage());
|
}
|
}
|
}
|
|
/*
|
* Location:
|
* C:\Users\LiJun\Desktop\公司各种设备资料\9600显示模块相关文件\后台程序\2018-09-07\BattFBS9600XSP.
|
* jar Qualified Name: com.base.Com JD-Core Version: 0.6.2
|
*/
|