提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用日期类
import java.util.Date; /* *来 自 n o w j a v a . c o m - 时 代 Java */ public class Main { public static void main (String[] args) { // Create a new Date object Date currentDate = new Date(); System.out.println("Current date: " + currentDate); // Get the milliseconds value of the current date long millis = currentDate.getTime(); System.out.println("Current datetime in millis: " + millis); } }