Java date and time comparison

Source: Internet
Author: User

Timestamp crsd = verifyitem. getrequestshipdate ();
Calendar Cal = calendar. getinstance ();
Calendar now = calendar. getinstance ();
Calendar calcrsd = calendar. getinstance ();
Calcrsd. settimeinmillis (crsd. gettime ());
Cal. Set (calcrsd. Get (calendar. Year ),
Calcrsd. Get (calendar. month ),
Calcrsd. Get (calendar. Date), 0, 0, 0 );
Cal. Add (calendar. Date,-leadtime); // If delivery is allowed three days in advance, and the customer requests delivery on the 8 th, delivery can be allowed as early as five days.
Now. Set (now. Get (calendar. Year), now. Get (calendar. month), now. Get (calendar. Date), 0, 0, 0 );

If (now. compareto (CAL) <0 ){
Simpledateformat df = new simpledateformat ("yyyy-mm-dd ");
Infos. Add ("Order [Ticket No.:" + So + ", row number:" + soline
+ "] Not included in the plan! Reason: orders to be scheduled can only be placed in advance "+ leadtime
+ "Daily delivery of goods [the date of delivery requested by the customer is" + DF. Format (calcrsd. gettime ())
+ ", The earliest date allowed for delivery is" + DF. Format (Cal. gettime () + "]! ");
Fails. Add (verifyitem. GETID ());
Removeids. Add (verifyitem );
Continue;
}

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.