标签:date 区分 字符 print stat 说明 time highlight 时间
public static void main(String[] args) {
DateTimeFormatter dateTimeFormatter=DateTimeFormatter.ofPattern("yy-MM-dd");
LocalDate localDateTime=LocalDate.now();
localDateTime.format(dateTimeFormatter);
System.out.println(localDateTime);
String time="2018-05-18 23:24:25";
DateTimeFormatter dateTimeFormatter2=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");//严格遵守大小写
LocalDateTime localDate=LocalDateTime.parse(time,dateTimeFormatter2);
LocalDate localDate1=LocalDate.of(localDate.getYear(),localDate.getMonth(),localDate.getDayOfMonth());
System.out.println(localDate1);//2018-05-18
}
说明: jdk1.8 严格区分LocalDate(日期) LocalDateTime(时间日期) LocalTime(时间)
标签:date 区分 字符 print stat 说明 time highlight 时间
原文地址:https://www.cnblogs.com/jinjian91/p/9058548.html