Data

(1) Include a Data class in the standard Java class library. Its object represents a specific instant, accurate to the millisecond

(2) The representation of time in Java is also a number, which is the number of milliseconds from 0:00 on January 1, 1970 of the standard era to a certain moment, the type is long

  import java.util.Date;

  Date d = new Date(); //No-argument constructor, representing the current moment

  System,out.println(d); //Print time

  System.out.println(d.getTime()); //Get the long value of time

  Date d2 = new Date(3600); //Constructor with parameters, the unit is milliseconds

  System,out.println(d2.toGMTString()); //The printing time is 1:00 on January 1, 1990. If .toGMTString() is not added, it will print 9:00 Beijing time

  d2.setTime(1000); //Reset the time

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325167896&siteId=291194637