在jdk1.6我们所使用的是Date 日期类通过SimpleDateFormat进行格式的转换,但是在1.8版本中,发现有人采用了
LocalDateTime来使用,可以获取当前日期 当前也分 当前月 到毫秒。二常用的日期类型 只精确到了秒。
所以我认为基本的使用还是需要掌握一下的。但是类型之间,初步写的一个小东西。
package cn.com.taiji.lighting;
import java.time.LocalDateTime;
import java.time.chrono.Chronology;
import java.time.format.DateTimeFormatter;
public class LocalDateT {
public static void main(String[] args) {
LocalDateTime localDate = LocalDateTime.now();// 代表的是当前的时间
System.out.println(localDate);// 打印内容2018-05-09T13:25:08.273
DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("yyyy:MM:dd HH:MM:ss");
String format = ofPattern.format(localDate);
System.out.println(format);
}
}