Java获取当前时间精确到毫秒

// 方法1
new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
 
 
// 方法2
Calendar cld = Calendar.getInstance();
int YY = cld.get(Calendar.YEAR);
int MM = cld.get(Calendar.MONTH)+1;
int DD = cld.get(Calendar.DATE);
int HH = cld.get(Calendar.HOUR_OF_DAY);
int mm = cld.get(Calendar.MINUTE);
int SS = cld.get(Calendar.SECOND);
int MI = cld.get(Calendar.MILLISECOND);
 
String curTime = YY + MM + DD + HH + mm + SS + MI;

 

posted @ 2019-10-21 14:54  寓言i  阅读(12917)  评论(0编辑  收藏  举报