Date class
1.java.lang.system class
The public static long Currenttimemillis () provided by the system class is used to return the time difference in milliseconds between the current and January 1, 1970 0:0 0 seconds
2. Java.util.Date class: Indicates a specific moment, accurate to milliseconds
① Construction Method:
The date () object created using the parameterless construction method of the date class can get the local current time.
Date (long date)
② Common methods
GetTime (): Returns the number of milliseconds represented by this Date object since January 1, 1970 00:00:00 GMT.
ToString (): Converts this Date object to the following form of String:dow mon dd hh:mm:ss zzz yyyy
Where: Dow is a day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat), ZZZ is the time standard.
Note: The API of the date class is not easy to internationalize, most of it is discarded,
3.java.text.simpledateformat class: is a specific class that formats and resolves dates in a way that is not related to the locale.
It allows formatting (date text), parsing (text date)
Formatting:
SimpleDateFormat (): Default schema and Locale creation object
Public SimpleDateFormat (String pattern): The construction method can create an object in the format specified by the parameter pattern, which invokes:
Public String Format (date date): Method format Time Object date
Analytical:
Public Date Parse (string source): Parses the text from the beginning of the given string to generate a date
4.java.util.calendar (Calendar) class
The calendar is an abstract base class that is used to perform the functions of interacting between date fields.
① how to get a calendar instance
Using the Calendar.getinstance () method
The constructor that invokes its subclass GregorianCalendar.
② Common methods
An instance of the calendar is an abstract representation of system time,
Use the Get (int field) method to get the time information you want. such as year, MONTH, Day_of_week, Hour_of_day, MINUTE, SECOND
public void Set (int field,int value)
public void Add (int field,int amount)
Public final Date GetTime ()
Public final void SetTime (date date)
Date of Java