集册 Java实例教程 使用日期类

使用日期类

欢马劈雪     最近更新时间:2020-01-02 10:19:05

403
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用日期类

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);    }

}