时间与日期
旧
Date dNow = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println(sdf.format(dNow));
console : 2018-12-04 17:39:08
新
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime ldt = LocalDateTime.now(); System.out.println(dtf.format(ldt));
console : 2018-12-04 17:39:08