Java Utililty Methods Week Day

List of utility methods to do Week Day

Description

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

Method

StringgetFirstDayOfWeek(String str, int week)
get First Day Of Week
String conStr = null;
int dayOfWeek = 0;
if (week == 0) {
    conStr = str;
    dayOfWeek = getCalendar(conStr).get(Calendar.DAY_OF_WEEK);
} else {
    conStr = addDays(str, week * 7);
    dayOfWeek = getCalendar(conStr).get(Calendar.DAY_OF_WEEK);
...
StringgetFirstDayOfWeek(String week)
get First Day Of Week
try {
    return getDefaultDateFormat().format(getDefaultWeekFormat().parse(week));
} catch (ParseException e) {
    return "ERROR_DAY";
StringgetFirstDayOfWeek(String week)
get First Day Of Week
try {
    return getDefaultDateFormat().format(getDefaultWeekFormat().parse(week));
} catch (ParseException e) {
    return "ERROR_DAY";
StringgetFriday(Date date)
get Friday
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
return new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
DategetLastDayOfCurrWeek()
get Last Day Of Curr Week
Calendar c = new GregorianCalendar();
c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); 
c.set(Calendar.MILLISECOND, 999);
c.set(Calendar.SECOND, 59);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.HOUR_OF_DAY, 23);
return c.getTime();
intgetLastDayOfWeek(int year, int month)
get Last Day Of Week
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DATE, 0);
return calendar.get(Calendar.WEEK_OF_MONTH);
StringgetLastSundayBeforeThisWeek()
get Last Sunday Before This Week
Calendar c = Calendar.getInstance();
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
if (dayOfWeek == 0) {
    dayOfWeek = 7;
c.add(Calendar.DATE, -dayOfWeek);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(c.getTime());
...
CalendargetLastWeekday()
get Last Weekday
return getLastWeekday(getYesterday());
DategetLastWeekDay(int weekDay)
get Last Week Day
return getLastWeekDay(weekDay, new Date());
DategetLastWeekDay(int weekDay)
Get the last date in the specified week day counted from today.
return getLastWeekDay(weekDay, new Date());