1.Date of two methods:
1 Public Long getTime (): Gets the time, in milliseconds 2 Public void settime (long ): Set time
2. code example:
1 Packagecn.itcast_02;2 3 Importjava.util.Date;4 5 /*6 * Public Long getTime (): Gets the time, in milliseconds7 * public void settime (long): Set time8 * 9 * get a millisecond value from date Ten * GetTime () One * Converts a millisecond value to date A * Construction Method: Public date (long date): Creates a Date object based on the given millisecond value - * SetTime (long time) - */ the Public classDatedemo { - Public Static voidMain (string[] args) { - //Creating Objects -Date d =NewDate (); + - //Get Time + LongTime =d.gettime (); A System.out.println (time); at //System.out.println (System.currenttimemillis ()); - -System.out.println ("D:" +d); - //Set the time -D.settime (1000); -System.out.println ("D:" +d); in } -}
The results are as follows:
Java Basics Hardening Date and millisecond conversions in the data class of the 91:date class