/**
* 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;
}

 

// 获取当前系统时间——UUID-不安全
public static String getCurTimeUUID() {
return getCurTime("yyyyMMddHHmmssSSS");
}

// 指定格式获取当前系统时间-线程不安全
public static String getCurTime(String formatStr) {
Date date = new Date(System.currentTimeMillis());
SimpleDateFormat dateFormat = new SimpleDateFormat(formatStr);
String curString = dateFormat.format(date);
return curString;
}

相关文章:

  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
猜你喜欢
  • 2022-12-23
  • 2021-09-24
  • 2022-02-09
  • 2021-12-19
  • 2022-12-23
  • 2021-12-10
  • 2022-01-16
相关资源
相似解决方案