首页 > 技术文章 > 获取当前系统时间工具类TimeUtils

juzijiang 2018-09-26 16:18 原文

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

}

 

个人记录之用!

 

推荐阅读