Java Utililty Methods Day of Week

List of utility methods to do Day of Week

Description

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

Method

intgetWeekday(Date d)
determines the day of the week
if (d == null) {
    return -1;
Calendar cal = Calendar.getInstance();
cal.setTime(d);
int w = cal.get(Calendar.DAY_OF_WEEK);
return w;
intgetWeekDay(Date d)
get Week Day
if (d == null)
    return -1;
final Calendar c = new GregorianCalendar();
c.setTime(d);
return c.get(Calendar.DAY_OF_WEEK) - 1;
intgetWeekDay(Date date)
Get the week day of the specified date.
GregorianCalendar cal = getCalender(date, false);
return cal.get(Calendar.DAY_OF_WEEK);
StringgetWeekDay(Date date)
get Week Day
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int idx = cal.get(Calendar.DAY_OF_WEEK) - 1;
return WEEK_DAYS[idx];
intgetWeekDay(Date date)
get Week Day
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
return cal.get(Calendar.DAY_OF_WEEK);
intgetWeekDay(Date date)
Return week day of specified date
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.DAY_OF_WEEK);
DategetWeekDay(Date dt, int weekDay)
get Week Day
Calendar cal = new GregorianCalendar();
cal.setTime(dt);
if (weekDay == 7)
    weekDay = 1;
else
    weekDay++;
cal.set(GregorianCalendar.DAY_OF_WEEK, weekDay);
return cal.getTime();
...
intgetWeekDay(String strDate)
get Week Day
Calendar cal = parseDateTime(strDate);
return cal.get(Calendar.DAY_OF_WEEK);
DategetWeekdayDate(Date actualDate)
get Weekday Date
final Calendar calendar = Calendar.getInstance();
calendar.setTime(actualDate);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
final Date newDate = calendar.getTime();
if (newDate.before(actualDate)) {
    calendar.add(Calendar.WEEK_OF_YEAR, Calendar.SATURDAY);
return calendar.getTime();
...
intgetWeekdayInterval(Date date)
get Weekday Interval
List<String> holidays = Arrays.asList(Holidays);
Calendar now = Calendar.getInstance();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int d = (int) ((now.getTimeInMillis() - calendar.getTimeInMillis()) / (24 * 60 * 60 * 1000));
int n = 0;
for (int i = 0; i < d; i++) {
    calendar.add(Calendar.DATE, 1);
...