LocalDate获取指定格式日期
使用JDK8中的LocalDate类:
public static void main(String[] args) {
LocalDate nowDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
String format = nowDate.format(formatter);
System.out.println(format);
}
控制台输出:
20191023
还没有评论,来说两句吧...