Get 10 business days before the date Java

Source: Internet
Author: User

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

Related Article

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.