Date class in java. util
Www.linuxaid.com.cn 01-09-20 496 p everywhere
--------------------------------------------------------------------------------
In JSP, we often need to process date and time information. In this case, you can use java. the Date class in util is obvious when writing Java source programs. You must use the "import java. util. * "introduces java. util software package. When compiling JSP source code, because Date is not the default object of JSP, you still have to use "<% @ page import =" java. util. * "" introduces this software package. In addition. SQL contains a Date class with the same name. To divide the two into correct regions, java is used. you 'd better write the Date class in util in java. util. date.
In fact, the Date class does not only represent the Date, but is precise to milliseconds. From this perspective, it may be more appropriate to call it DateTime. In this article, we sometimes call Date as a Date, hoping it will not cause readers to misunderstand.
When talking about the Date class in java. util, we often mention UTC and GMT, which are almost the same concept. They all refer to the Greenwich Standard Time, But UTC is more formal. The difference between the two lies in that the former is an astronomical concept, while the latter is based on an atomic clock. In UTC, there is a "leap second" every year or two years, but we generally ignore this "leap second", but in Java, this sometimes results in 60 s or 61 s.
There are corresponding methods in the Date class. It can divide the Date into years, months, days, hours, minutes, and seconds and convert it into a string, it can also perform reverse operations. However, since JDK1.1, the Calendar class and Date Format class can also execute these two types of functions. According to the official Java file, the corresponding methods in the Date class are no longer recommended. However, there is no big difference in principle between the two. In this article, we will continue to introduce these methods, but will make corresponding notes.
In all cases, the parameters accepted by these methods do not need to meet the valid range; for example, if a date is defined as January 2, January 3, it will be interpreted as January 1, February 1.
1. Date constructor
1.1 construct a Date instance that reflects the current time
Date
Public Date ()
Construct a Date object and initialize it to reflect the current time.
1.2 construct a Date instance from a long integer
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.