用途:在项目中一些属性中设置当前时间
实例代码
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class time {
public static void main(String[] args){
LocalDateTime china = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
System.out.println((china.format(formatter)));
}
}
运行结果