Javaimplement date arbitrary jump
During the project development process, it is necessary to set up the order reminder date, which mainly includes setting the monthly specified date or the specified number of days, the code is as follows:
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;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Tools Class (iv) Implementation date any jump