Java Code Examples for android.text.format.Time#THURSDAY

The following examples show how to use android.text.format.Time#THURSDAY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventRecurrence.java    From SublimePicker with Apache License 2.0 6 votes vote down vote up
public static int timeDay2Day(int day) {
    switch (day) {
        case Time.SUNDAY:
            return SU;
        case Time.MONDAY:
            return MO;
        case Time.TUESDAY:
            return TU;
        case Time.WEDNESDAY:
            return WE;
        case Time.THURSDAY:
            return TH;
        case Time.FRIDAY:
            return FR;
        case Time.SATURDAY:
            return SA;
        default:
            throw new RuntimeException("bad day of week: " + day);
    }
}
 
Example 2
Source File: EventRecurrence.java    From SublimePicker with Apache License 2.0 6 votes vote down vote up
public static int day2TimeDay(int day) {
    switch (day) {
        case SU:
            return Time.SUNDAY;
        case MO:
            return Time.MONDAY;
        case TU:
            return Time.TUESDAY;
        case WE:
            return Time.WEDNESDAY;
        case TH:
            return Time.THURSDAY;
        case FR:
            return Time.FRIDAY;
        case SA:
            return Time.SATURDAY;
        default:
            throw new RuntimeException("bad day of week: " + day);
    }
}
 
Example 3
Source File: RecurrenceUtils.java    From SublimePicker with Apache License 2.0 6 votes vote down vote up
/**
 * Converts the day of the week from android.text.format.Time to java.util.Calendar
 */
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");
    }
}
 
Example 4
Source File: EventRecurrence.java    From Android-RecurrencePicker with Apache License 2.0 6 votes vote down vote up
public static int timeDay2Day(int day) {
    switch (day) {
        case Time.SUNDAY:
            return SU;
        case Time.MONDAY:
            return MO;
        case Time.TUESDAY:
            return TU;
        case Time.WEDNESDAY:
            return WE;
        case Time.THURSDAY:
            return TH;
        case Time.FRIDAY:
            return FR;
        case Time.SATURDAY:
            return SA;
        default:
            throw new RuntimeException("bad day of week: " + day);
    }
}
 
Example 5
Source File: EventRecurrence.java    From Android-RecurrencePicker with Apache License 2.0 6 votes vote down vote up
public static int day2TimeDay(int day) {
    switch (day) {
        case SU:
            return Time.SUNDAY;
        case MO:
            return Time.MONDAY;
        case TU:
            return Time.TUESDAY;
        case WE:
            return Time.WEDNESDAY;
        case TH:
            return Time.THURSDAY;
        case FR:
            return Time.FRIDAY;
        case SA:
            return Time.SATURDAY;
        default:
            throw new RuntimeException("bad day of week: " + day);
    }
}
 
Example 6
Source File: Utils.java    From Android-RecurrencePicker with Apache License 2.0 6 votes vote down vote up
/**
 * Converts the day of the week from android.text.format.Time to java.util.Calendar
 */
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");
    }
}
 
Example 7
Source File: Utils.java    From narrate-android with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
 * adjusted for first day of week.
 *
 * 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;
}
 
Example 8
Source File: Utils.java    From ClockPlus with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
 * adjusted for first day of week.
 *
 * 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;
}
 
Example 9
Source File: Utils.java    From BottomSheetPickers with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
 * adjusted for first day of week.
 *
 * 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;
}
 
Example 10
Source File: Utils.java    From Android-RecurrencePicker with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the week since {@link android.text.format.Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
 * adjusted for first day of week.
 * <p/>
 * This takes a julian day and the week start day and calculates which
 * week since {@link android.text.format.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 android.text.format.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;
}
 
Example 11
Source File: Utils.java    From DateTimepicker with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
 * adjusted for first day of week.
 *
 * 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;
}
 
Example 12
Source File: Utils.java    From StyleableDateTimePicker with MIT License 3 votes vote down vote up
/**
 * Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
 * adjusted for first day of week.
 *
 * 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;
}
 
Example 13
Source File: Utils.java    From cathode with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
 * adjusted for first day of week.
 *
 * 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;
}