UUID timestamp

/**
* 32位去除'-'的UUID
*/
public static String getUUID() {
String uuid = java.util.UUID.randomUUID().toString();
uuid = uuid.replace("-", "");
return uuid;
}

/**
* 获取现在时间
*
* @return 返回时间类型yyyyMMddHHmmssSSS
*/
public static String getNowDate() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String dateString = formatter.format(currentTime);
return dateString;
}

 

// Get current system time --uuid
public static String getCurTimeUUID () {
return getCurTime ( "yyyyMMddHHmmssSSS");
}

// get the current system time specified format
public static String getCurTime (String formatStr) {
a Date = new new DATE a Date (System.currentTimeMillis ());
the SimpleDateFormat the dateFormat the SimpleDateFormat new new = (formatStr);
String curString = dateFormat.format (DATE);
return curString;
}

Guess you like

Origin www.cnblogs.com/sung1024/p/11210730.html