获取当前系统时间工具类TimeUtils

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

}

 

个人记录之用!

 

posted @ 2018-09-26 16:18  橘子、酱  阅读(1147)  评论(0编辑  收藏  举报