Date class
What is the role of the Date class?
It is used to manage dates and times.
The Date class comes from java. util. Date
Two constructors of the Date class
The object constructed by the. Date () constructor is related to the current Date and time of the system.
B. Date (long t); The constructed object is the object of the specified time.
Common Methods for Date classes
GetTime (); converts data in the Date class to a time in milliseconds.
After ();
Before ();
1 second = 1000 milliseconds
Date and Time formatting:
Formatted output of date and time
1) System. out. printf ("format controller", d1 );
Format Controller: It starts with % t and is followed by a letter. For example:
% TF
% TT
% TA
2) String. format ("format controller", d1 );
Its format is exactly the same as that of the printf () method. But what it gets is a string, and prinf () is printed directly to the screen.
3) use the DateFormat class to format the date and time.
4) use the SimpleDateFormat class to format the date and time.
3) use the DateFormat class to format the date and time.
The DateFormat class comes from java. text. DateFormat (text package ):
2. It is used to format the date and time.
* At the same time, you can restore a date string to a date object.
Use the SimpleDateFormat class to format the date and time.
1. SimpleDateFormat class comes from java. text. SimpleDateFormat;
2. It is the son of the DateFormat class (subclass ).
3. SimpleDateFormat class is used to format the date and time. At the same time, Date and time strings can be restored to Date objects.
It features flexible object Date and Time formatting.
Newline !!!