Example usage for android.text.format Time THURSDAY

List of usage examples for android.text.format Time THURSDAY

Introduction

In this page you can find the example usage for android.text.format Time THURSDAY.

Prototype

int THURSDAY

To view the source code for android.text.format Time THURSDAY.

Click Source Link

Usage

From source file:Main.java

/**
 * Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
 * adjusted for first day of week./* w  ww .ja  v a2  s . c om*/
 * <p/>
 * This takes a julian day and the week start day and calculates which
 * week since {@link Time#EPOCH_JULIAN_DAY} that day occurs in, starting
 * at 0. *Do not* use this to compute the ISO week number for the year.
 *
 * @param julianDay      The julian day to calculate the week number for
 * @param firstDayOfWeek Which week day is the first day of the week,
 *                       see {@link Time#SUNDAY}
 * @return Weeks since the epoch
 */
public static int getWeeksSinceEpochFromJulianDay(int julianDay, int firstDayOfWeek) {
    int diff = Time.THURSDAY - firstDayOfWeek;
    if (diff < 0) {
        diff += 7;
    }
    int refDay = Time.EPOCH_JULIAN_DAY - diff;
    return (julianDay - refDay) / 7;
}

From source file:Main.java

/**
 * Converts the day of the week from android.text.format.Time to java.util.Calendar
 */// ww  w  .ja  v a  2  s . co  m
public static int convertDayOfWeekFromTimeToCalendar(int timeDayOfWeek) {
    switch (timeDayOfWeek) {
    case Time.MONDAY:
        return Calendar.MONDAY;
    case Time.TUESDAY:
        return Calendar.TUESDAY;
    case Time.WEDNESDAY:
        return Calendar.WEDNESDAY;
    case Time.THURSDAY:
        return Calendar.THURSDAY;
    case Time.FRIDAY:
        return Calendar.FRIDAY;
    case Time.SATURDAY:
        return Calendar.SATURDAY;
    case Time.SUNDAY:
        return Calendar.SUNDAY;
    default:
        throw new IllegalArgumentException("Argument must be between Time.SUNDAY and " + "Time.SATURDAY");
    }
}