Here you can find the source of getEndDate(String date)
public static String getEndDate(String date)
//package com.java2s; import java.util.Calendar; public class Main { public static String getEndDate(String date) { String endDate;/*from ww w . jav a 2 s . c o m*/ int year = getYear(date); int month = getMonth(date); int day = getDate(date); int curDayOfWeek = getDayOfWeek(year, month, day); int endTmp = 7 - curDayOfWeek; Calendar tmpCalendar = Calendar.getInstance(); tmpCalendar.set(year, month - 1, day); tmpCalendar.add(Calendar.DATE, endTmp); endDate = Integer.toString(tmpCalendar.get(Calendar.YEAR)); if ((tmpCalendar.get(Calendar.MONTH) + 1) < 10) endDate += "0"; endDate += Integer.toString((tmpCalendar.get(Calendar.MONTH)) + 1); if (tmpCalendar.get(Calendar.DATE) < 10) endDate += "0"; endDate += Integer.toString(tmpCalendar.get(Calendar.DATE)); return endDate; } public static int getYear(String date) { return Integer.parseInt(date.substring(0, 4)); } public static int getMonth(String date) { return Integer.parseInt(date.substring(4, 6)); } public static int getDate(String date) { return Integer.parseInt(date.substring(6, 8)); } public static int getDayOfWeek(int _year, int _month, int _day) { int year, month, date; Calendar cal = Calendar.getInstance(); cal.set(_year, _month - 1, _day); return cal.get(Calendar.DAY_OF_WEEK); } }