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

intgetDayWithWeek(Date date)
get Day With Week
int day = getNumberFromDate(date, Calendar.DAY_OF_WEEK);
if (day == 1) {
    return 7;
return day - 1;
StringgetENWeekDay()
get EN Week Day
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w < 0)
    w = 0;
return WEEKDAYS_EN[w];
ListgetFirstday_Lastday_Week()
get Firstda Lastda Week
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
int w = calendar.get(Calendar.DAY_OF_WEEK);
calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) - w);
String day_last = df.format(calendar.getTime());
StringBuffer str = new StringBuffer().append(day_last).append(" 23:59:59");
day_last = str.toString();
...
DategetFirstDayOfLastWeek(Date date)
get First Day Of Last Week
Calendar c = Calendar.getInstance();
c.setTimeInMillis(date.getTime() - 604800000L);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
Date lastWeekDate = c.getTime();
c = new GregorianCalendar();
c.setFirstDayOfWeek(Calendar.MONDAY);
...
intgetFirstDayOfWeek()
get First Day Of Week
return firstDayOfWeek;
intgetFirstDayOfWeek()
Retrieve the first day of the week using the systems default locale.
if (_firstDayofWeek != -1) {
    return _firstDayofWeek;
Calendar cal = Calendar.getInstance();
_firstDayofWeek = cal.getFirstDayOfWeek();
return _firstDayofWeek;
DategetFirstDayOfWeek(Date date)
get First Day Of Week
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return getADayOfWeek(calendar, Calendar.MONDAY).getTime();
DategetFirstDayOfWeek(Date date)
get First Day Of Week
Calendar c = new GregorianCalendar();
c.setFirstDayOfWeek(Calendar.SUNDAY);
c.setTime(date);
c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); 
return c.getTime();
DategetFirstDayOfWeek(final Date date)
get First Day Of Week
if (dayOfWeek(date) == 1) {
    return addDays(date, -6);
return addDays(date, -1 * (dayOfWeek(date) - 2));
StringgetFirstDayOfWeek(String format)
get First Day Of Week
return getDayOfWeek(format, Calendar.MONDAY);