Date, DateFormat, SimpleDateFormate

Source: Internet
Author: User
Tags time in milliseconds

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 !!!
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.