A Date Object Represents a Precise Moment In Time, Down To The Millisecond. Dates Are RepreSented As a Long That Count, January 1, 1970, Greenwich Mean Time.
Does this have a year 2000 problem? If so in what year?
TO CREATE A DATE OBJECT for the current date and time use the noke this:
Date now = new date ();
To create a date Object for a Specific Time, Pass The Number of Milliseconds Since Midnight, January, 1970, Greenwich Meantime To The Constructor, Like this:
Date midnight_jan2_1970 = new date (24L * 60L * 60L * 1000L);
You can return the number of milliiseconds in the date as a long, using the gettime () method. For example, to time a black of code, you might do this
Date D1 = new date ();
// Timed Code Goes Here
Date d2 = new date ();
Long elapsed_time = d2.gettime () - D1.GETTIME ();
System.out.println ("That TOOK" ELAPSED_TIME "MilliseConds");
You can change a date by passing the new date as a Number of MilliseConds Since Midnight, January 1, 1970, GMT, To The SetTime () Method, Like this:
Date Midnight_JAN2_1970 = New Date ();
Midnight_jan2_1970.settime (24L * 60L * 60L * 1000L);
The Before () Method Returns True if this date is before the date argument, false if it's not. For example
IF (midnight_jan2_1970.before (new date ())) {
The at () Method Returns True if this date is after the date argument, false if it's not. For example
IF (midnight_jan2_1970.af ") {
....................