Java Tools Class (iv) Implementation date random jump

Source: Internet
Author: User

Javaimplement date random jump

During the project development process. The setting of the order reminder date is required. The main include setting the monthly specified date or the specified number of days, code such as the following:

public static string Dateoperation (string type, date mydate, int num) {string date = null; SimpleDateFormat formatter = new SimpleDateFormat ("YyyyMMdd"); try {Calendar c = calendar.getinstance (); C.settime (mydate), if (Type.equals ("0")) {C.add (calendar.month, 1); mydate = C.gettime ();d ate = Formatter.format (mydate); String dt = date.substring (Date.length () -2,date.length ()); System.out.println ("date after interception: [" + dt + "]"); int days = num-integer.parseint (DT); System.out.println ("Days of Difference:" + day); C.add (calendar.date); mydate = C.gettime ();d ate = Formatter.format (mydate);} else if (type.equals ("1")) {C.add (calendar.date, num); mydate = C.gettime ();d ate = Formatter.format (mydate);} System.out.println ("Order Next Reminder Date: [" + Date + "]");} catch (Exception E1) {e1.printstacktrace ();} return date;}


Java Tools Class (iv) Implementation date random jump

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.