TimeUtils:
package com.duocy.util;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class TimeUtils {
/* public static String getTime() {
Date date = new Date();
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
String dt=dateFormat.format(date);
System.out.println("当前系统时间:"+dt);
return dt;
}*/
public static String getTime() {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
LocalDateTime time = LocalDateTime.now();
String localTime = df.format(time);
System.out.println(localTime);
return localTime;
}
}
个人记录之用!