public static date Getworkday (date startdate, int workDay) {
Calendar C1 = Calendar.getinstance ();
C1.settime (StartDate);
for (int i = 0; i < WorkDay; i++) {
C1.set (Calendar.date, C1.get (calendar.date) + 1);
if (Calendar.saturday = = C1.get (calendar.saturday) | | Calendar.sunday = = C1.get (calendar.sunday)) {
WorkDay = WorkDay + 1;
C1.set (Calendar.date, C1.get (calendar.date) + 1);
Continue
}
}
SimpleDateFormat df = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
System.out.println (Df.format (C1.gettime ()) + "" + getweekofdate (C1.gettime ()));
return C1.gettime ();
}
/**
* According to the date, get the day of the week
* @param DT
* @return String type
* @author "Baboon: Q9715234"
* @time 2015-11-23 9:21:25
* @motto Since the stupid home, will work hard to get home ...
*/
public static String getweekofdate (Date dt) {
String[] weekdays = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
Calendar cal = Calendar.getinstance ();
Cal.settime (DT);
int w = cal.get (Calendar.day_of_week)-1;
if (W < 0) w = 0;
return WEEKDAYS[W];
}
Get 10 business days before the date Java