Java.util.Date after and before, equal

Source: Internet
Author: User

 After (Date when)
Returns if and only if the moment represented by this Date object is later than the instant represented by the when true false .
before (Date when)
Returns if and only if the moment represented by this Date object is earlier than the instant represented by the when true false .

equals (Object obj)
Compares the equality of two dates. The result is only if and only if the argument null is not, and is an object that represents the same point in time (to milliseconds) as this object Date true .
Therefore, both objects are equal when and only if getTime Date the method returns the same value for two objects long .


Date1.after (Date2), when Date1 is greater than Date2, returns True when less than equals, returns false;

Date1.before (Date2), when Date1 is less than Date2, returns True when greater than equals returns false;

To verify that Date2 must be smaller than Date1 and not equal, use! Date1.after (DATE2)

Java.util.Date after and before, equal

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.