Get current date and time using java.util.Date class - Java Date Time

Java examples for Date Time:Legacy Date

Description

Get current date and time using java.util.Date class

Demo Code

import java.util.Date;

public class Main {
  public static void main(String[] args) {
    Date date = new Date();

    System.out.println("Using java.util.Date(): " + date);
    System.out.println("Getting time from java.util.Date(): " + date.getTime());

  }/*from  www.  j a  va 2  s . c  om*/

}

Result


Related Tutorials