Using a Class
This declares object today to have type class
- Date today
- Date() is Constructor of Date class which constructs an instance of Date class and sets default value to be the current date
- new Date()
- Note that there are two constructor methods in this class, as in general Java allows overloading of methods (but not operators).
An example application using a method of the Date class:
- import java.util.Date;
- class DateTest
- { public static void main ( String[ ] args)
- { Date today = new Date();
- Date early = new Date(1000);
- if (today.after (early))
- System.out.println( "Today is not early!");
- }}