📄 cansend.java
字号:
package com.gps.center.parsedata;
import java.util.Date;
import java.text.SimpleDateFormat;
//实现数组和十六进制的转化
public class CanSend {
// public CanSend() {
// }
public static boolean CanSendMsg(Date DeviceDate) {
/*
String date = "2005-05-06 13:12:05";
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date b = sf.parse(date);
*/
boolean cansend = false;
Date currentDate = new Date();
long c = (currentDate.getTime() - DeviceDate.getTime()) / (1000 * 60);
if (c < 8) {
cansend = true;
}
return cansend;
}
public static String getDateTime() {
/*
String date = "2005-05-06 13:12:05";
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date b = sf.parse(date);
*/
String currentDateTime = null;
Date currentDate = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
currentDateTime = sf.format(currentDate);
return currentDateTime;
}
public static String getTime() {
/*
String date = "2005-05-06 13:12:05";
SimpleDateFormat sf = new SimpleDateFormat("HHmmss");
java.util.Date b = sf.parse(date);
*/
String currentTime = null;
Date currentDate = new Date();
SimpleDateFormat sf = new SimpleDateFormat("HHmmss");
currentTime = sf.format(currentDate);
return currentTime;
}
/**
* 将字节码数组转换为16进制字符串
* @param b 输入的字节码数组
* @return 输出的16进制字符串
*/
public static String byte2hex(byte[] b) {
StringBuffer sb = new StringBuffer();
for (int n = 0; n < b.length; n++) {
if ( ( (int) b[n] & 0xff) < 0x10) {
sb.append("0");
}
sb.append(Integer.toHexString(b[n] & 0xFF));
}
return String.valueOf(sb);
}
/**
* 将16进制字符串转换为字节码数组
* @param b 输出的字节码数组
* @return 输入的16进制字符串
*/
public static byte[] strToHex(String st) {
byte[] bt = new byte[1];
bt = st.getBytes();
return bt;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -