Skip to Content

Simple Java Date Example

  1. /*
  2. Java Date example.
  3. This Java Date example describes how Java Date class is being used in Java language.
  4. */
  5.  
  6. import java.util.*;
  7.  
  8. /*
  9. Most of the methods of the Java Date class have been depricated.
  10. Java Calendar class should be used for date manipulation instead.
  11. */
  12.  
  13. public class JavaDateExample{
  14.  
  15.   public static void main(String args[]){
  16.   /*
  17.   Create date object with current date and time.
  18.   */
  19.  
  20.   Date date = new Date();
  21.   System.out.println("Today is " + date);
  22.  
  23.   }
  24.  
  25. }
  26.  
  27. /*
  28. OUTPUT of the above given Java Date Example would be :
  29. Today is Sat Feb 04 18:10:21 IST 2005
  30. */