//毫秒值转换为日期
public static String millToDate(long millisecond){
Date d = new Date(millisecond);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
return sdf.format(d);
}
//日期转换为毫秒值
public static long dateToMilles(String date){
long time = 0;
SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMdd"); //时间格式
try {
time = dateformat.parse(date).getTime();//格式转换
} catch (java.text.ParseException e) {
e.printStackTrace();
}
return time;
}
//16进制转换为10进制
public static int hexToint(String hex_num){
int dec_num = Integer.parseInt(hex_num, 16);
return dec_num;
}
/**
* 16进制转2进制字符串
*
* @param hexString
* @return
*/
public static String hexString2binaryString(String hexString) {
if (hexString == null || hexString.length() % 2 != 0)
return null;
String bString = "", tmp;
for (int i = 0; i < hexString.length(); i++) {
tmp = "0000"
+ Integer.toBinaryString(Integer.parseInt(hexString
.substring(i, i + 1), 16));
bString += tmp.substring(tmp.length() - 4);
}
return bString;
}
/**
* bytes转换成十六进制字符串
*/
public static String byte2HexStr(byte[] a) {
String hs = "";
String stmp;
for (int n = 0; n < a.length; n++) {
stmp = (Integer.toHexString(a[n] & 0XFF));
if (stmp.length() == 1)
hs = hs + "0" + stmp;
else
hs = hs + stmp;
}
return hs.toUpperCase();
}
//16进制字符串转换为指定长度的字符串,不足补0
public static String hexLength(String hex,int length){
int l = hex.length();
if(l<length){
int s = length -l;
for(int i=0;i<s;i++){
hex ="0"+hex;
}
}
return hex;
}
给定一个日期转换为指定日期的字符串格式
public static String dateFormate1(String date ,String OriginalDf ,String destDf) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(OriginalDf);
Date d = sdf.parse(date);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(de