Package Com.day10.Date class;
Import Java.util.Date;
public class Demodate {
/**
* Common Objects (Overview of the date class and methods used) (master)
* Overview of the A:date class
* Class Date represents a specific moment, accurate to milliseconds.
* B: Construction method
* Public Date ()
* Public date (long date)
* C: Member method
* Public long GetTime ()
* public void SetTime (long time)
*/
public static void Main (string[] args) {
Date D1=new date ();//null parameter constructor
System.out.println (d1);//sat Dec 21:09:40 CST 2017, representing the current time
Date D2=new date (0);
System.out.println (D2);//thu Jan 08:00:00 CST 1970, why print out is 8 points instead of 0 points, because Beijing in the East eight district
System.out.println (D1.gettime ());//Gets the millisecond value of the current time
System.out.println (System.currenttimemillis ());//Gets the millisecond value of the current time
Date D3=new date ();
D3.settime (1000);//Set the millisecond value, change the time object, past 1000 milliseconds
SYSTEM.OUT.PRINTLN (D3);//thu Jan 08:00:01 CST 1970
}
}
Java-date class