java程序:
// 利用LocalDateTime生成格式为"yyyy-MM-dd HH:mm:ss"的当前时间DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");LocalDateTime now = LocalDateTime.now();String time1 = now.format(formatter);System.out.println(time1);// 利用SimpleDateFormat生成格式为"yyyy-MM-dd HH:mm:ss"的当前时间SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String time2 = sdf.format(new Date());System.out.println(time2);