// 创建一个包含当前时间的 Date 对象
Date currentDate = new Date();
System.out.println("当前时间: " + currentDate);
// 使用指定的时间戳创建 Date 对象
long specificTimeMillis = 1633072800000L; // 毫秒数,例如:2021-10-01 00:00:00 UTC
Date specificDate = new Date(specificTimeMillis);
System.out.println("指定时间: " + specificDate);
new Date()
:创建一个 Date
对象,表示当前的日期和时间。它使用系统当前的时间(以毫秒为单位)来初始化。new Date(long date)
:创建一个 Date
对象,表示自1970年1月1日00:00:00 UTC以来指定的毫秒数对应的时间。如果你需要更多关于 Date
类的详细信息,可以查阅 Java 官方文档。
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站