Java Date Time - Java Date() Constructor








Syntax

Date() constructor from Date has the following syntax.

public Date()

Example

In the following code shows how to use Date.Date() constructor.

import java.util.Date;
//  w w w.  jav a 2s .c om
public class Main{
  public static void main(String args[]) {
    Date date = new Date();

    System.out.println(date);

    long msec = date.getTime();
    System.out.println("Milliseconds since Jan. 1, 1970 GMT=" + msec);
  }
}

The output: