2. Java get next Sunday-Next Saturday time

Source: Internet
Author: User
Tags dateformat

string[] arrdate = new STRING[7];
string[] Arrweek = new STRING[7];

int mondayplus = 0;
Calendar cd = Calendar.getinstance ();
Get today is the day of the week, Sunday is the first, Tuesday is the second day ...
int dayOfWeek = Cd.get (Calendar.day_of_week)-1; Because according to China Monday

if (DayOfWeek = = 1) {
Mondayplus = 0;
} else {
Mondayplus = 1-dayofweek;
}

for (int i=0; i<7; i++) {
GregorianCalendar currentdate = new GregorianCalendar ();
Currentdate.add (gregoriancalendar.date, Mondayplus + 6 + i);
Date Monday = Currentdate.gettime ();
DateFormat df = dateformat.getdateinstance ();
SimpleDateFormat df = new SimpleDateFormat ("Yyyy-mm-dd EE");
String Premonday = Df.format (Monday);
string[] Strarr = Premonday.split ("");
Storage Date
Arrdate[i] = strarr[0];
How many days to store
Arrweek[i] = strarr[1];
System.out.println (arrdate[i]+ "," +arrweek[i]);
}

2. Java get next Sunday-Next Saturday time

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.