List of utility methods to do Week
String | getWeekStartDate(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; |
boolean | isSameWeek(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()); ... |
String | startOfWeek(Date date, String format) start Of Week SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(startOfWeek(date)); |
String | weekAgo() week Ago Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.DAY_OF_MONTH, -8); return convertDate2String5(cal.getTime()); |
Date | weeksFromNow(int amount) weeks From Now Calendar cal = Calendar.getInstance();
cal.add(Calendar.WEEK_OF_YEAR, amount);
return cal.getTime();
|