new Date() : Date « java.util « Java by API






new Date()

/*
 * Output: 

Tue Apr 25 13:25:27 PDT 2006
Wed Dec 31 16:00:00 PST 1969

 */

import java.util.Date;

public class MainClass {

  public static void main(String args[]) {
    Date currentDate = new Date();

    System.out.println(currentDate);

    // Get date object initialized to the epoch (Jan 1 1970)
    Date epoch = new Date(0);

    System.out.println(epoch);
  }
}
    
           
       








Related examples in the same category

1.new Date(int intValue)
2.Date: after(Date when)
3.Date: before(Date when)
4.Date: diff (Not a method)
5.Date: equals(Object anotherDate)
6.Date: getTime()
7.Date: setTime(long miliseconds)