时间
public class DateTimeUtil {
public static String getSysTime(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String dateStr = sdf.format(date);
return dateStr;
}
}
密码加密
public class MD5Util {
public static String getMD5(String password) {
try {
MessageDigest digest = MessageDigest.getInstance("md5");
byte[] result = digest.digest(password.getBytes());
StringBuffer buffer = new StringBuffer();
for (byte b : result) {
int number = b & 0xff;
String str = Integer.toHexString(number);
if (str.length() == 1) {
buffer.append("0");
}
buffer.append(str);
}
return buffer.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return "";
}
}
}
UUID
package com.cc.travel.utils;
import java.util.UUID;
public class UUIDUtil {
public static String getUUID(){
return UUID.randomUUID().toString().replaceAll("-","");
}
}