1. 程式人生 > >獲取當前系統時間工具類TimeUtils

獲取當前系統時間工具類TimeUtils

string public date() new edate 當前 com strong alt

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

}

個人記錄之用!

獲取當前系統時間工具類TimeUtils