Java Utililty Methods Week

List of utility methods to do Week

Description

The list of methods to do Week are organized into topic(s).

Method

StringgetWeekStartDate(Integer weekNumber)
get Week Start Date
String weekDate;
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.WEEK_OF_YEAR, weekNumber);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
weekDate = sdf.format(cal.getTime());
return weekDate;
booleanisSameWeek(Date curDate, Date compareDate)
is Same Week
if (curDate == null || compareDate == null) {
    return false;
Calendar calSun = Calendar.getInstance();
calSun.setTime(getFormatDateToDate(curDate));
calSun.set(Calendar.DAY_OF_WEEK, 1);
Calendar calNext = Calendar.getInstance();
calNext.setTime(calSun.getTime());
...
StringstartOfWeek(Date date, String format)
start Of Week
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(startOfWeek(date));
StringweekAgo()
week Ago
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_MONTH, -8);
return convertDate2String5(cal.getTime());
DateweeksFromNow(int amount)
weeks From Now
Calendar cal = Calendar.getInstance();
cal.add(Calendar.WEEK_OF_YEAR, amount);
return cal.getTime();