Android Utililty Methods Day of Week Get

List of utility methods to do Day of Week Get

Description

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

Method

StringgetDayOfWeekString(int dayOfWeek, int abbrev)
Return a string for the day of the week.
int[] list;
switch (abbrev) {
case LENGTH_LONG:
    list = sDaysLong;
    break;
case LENGTH_MEDIUM:
    list = sDaysMedium;
    break;
...
intgetDayofWeekInMonth(String year, String month, String weekOfMonth, String dayOfWeek)
get Dayof Week In Month
Calendar cal = new GregorianCalendar();
int y = new Integer(year).intValue();
int m = new Integer(month).intValue();
cal.clear();
cal.set(y, m - 1, 1);
cal.set(Calendar.DAY_OF_WEEK_IN_MONTH,
        new Integer(weekOfMonth).intValue());
cal.set(Calendar.DAY_OF_WEEK, new Integer(dayOfWeek).intValue());
...
intgetDayOfWeek(String year, String month, String day)
get Day Of Week
Calendar cal = new GregorianCalendar(new Integer(year).intValue(),
        new Integer(month).intValue() - 1,
        new Integer(day).intValue());
return cal.get(Calendar.DAY_OF_WEEK);
intgetDayOfWeek(String date)
get Day Of Week
String[] temp = null;
if (date.indexOf("/") > 0) {
    temp = date.split("/");
if (date.indexOf("-") > 0) {
    temp = date.split("-");
return getDayOfWeek(temp[0], temp[1], temp[2]);
...
intgetDayOfWeek(Date date)
get Day Of Week
Calendar cal = new GregorianCalendar();
cal.setTime(date);
return cal.get(Calendar.DAY_OF_WEEK);
intgetFirstDayOfWeek()
Get first day of week as android.text.format.Time constant.
int startDay = Calendar.getInstance().getFirstDayOfWeek();
if (startDay == Calendar.SATURDAY)
    return Time.SATURDAY;
else if (startDay == Calendar.MONDAY)
    return Time.MONDAY;
else
    return Time.SUNDAY;
intgetDayOfTheWeek(Date date)
get Day Of The Week
Calendar c = Calendar.getInstance();
c.setTimeInMillis(date.getTime());
return c.get(Calendar.DAY_OF_WEEK);
intgetDayOfWeekZeroIndexed(Date dateTime)
Returns the day of week as zero indexed.
final Calendar calendar = Calendar.getInstance();
calendar.setTime(dateTime);
final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
switch (dayOfWeek) {
case Calendar.MONDAY:
    return 0;
case Calendar.TUESDAY:
    return 1;
...
StringgetReadableWeekDay(int day)
get Readable Week Day
return WEEKDAY[day - 1];
StringgetStringDayOfWeek(Date date)
get String Day Of Week
SimpleDateFormat sdf = new SimpleDateFormat("EEEEE");
return sdf.format(date);