Java Code Examples for android.icu.util.Calendar#DAY_OF_WEEK

The following examples show how to use android.icu.util.Calendar#DAY_OF_WEEK . 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: DateIntervalInfo.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * Provides a way for client to build interval patterns.
 * User could construct DateIntervalInfo by providing
 * a list of skeletons and their patterns.
 * <P>
 * For example:
 * <pre>
 * DateIntervalInfo dIntervalInfo = new DateIntervalInfo();
 * dIntervalInfo.setIntervalPattern("yMd", Calendar.YEAR, "'from' yyyy-M-d 'to' yyyy-M-d");
 * dIntervalInfo.setIntervalPattern("yMMMd", Calendar.MONTH, "'from' yyyy MMM d 'to' MMM d");
 * dIntervalInfo.setIntervalPattern("yMMMd", Calendar.DAY, "yyyy MMM d-d");
 * dIntervalInfo.setFallbackIntervalPattern("{0} ~ {1}");
 * </pre>
 *
 * Restriction:
 * Currently, users can only set interval patterns when the following
 * calendar fields are different: ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH,
 * DAY_OF_WEEK, AM_PM,  HOUR, HOUR_OF_DAY, MINUTE, and SECOND.
 * Interval patterns when other calendar fields are different are
 * not supported.
 *
 * @param skeleton         the skeleton on which interval pattern based
 * @param lrgDiffCalUnit   the largest different calendar unit.
 * @param intervalPattern  the interval pattern on the largest different
 *                         calendar unit.
 *                         For example, if lrgDiffCalUnit is
 *                         "year", the interval pattern for en_US when year
 *                         is different could be "'from' yyyy 'to' yyyy".
 * @throws IllegalArgumentException  if setting interval pattern on
 *                            a calendar field that is smaller
 *                            than the MINIMUM_SUPPORTED_CALENDAR_FIELD
 * @throws UnsupportedOperationException  if the object is frozen
 */
public void setIntervalPattern(String skeleton,
                               int lrgDiffCalUnit,
                               String intervalPattern)
{
    if ( frozen ) {
        throw new UnsupportedOperationException("no modification is allowed after DII is frozen");
    }
    if ( lrgDiffCalUnit > MINIMUM_SUPPORTED_CALENDAR_FIELD ) {
        throw new IllegalArgumentException("calendar field is larger than MINIMUM_SUPPORTED_CALENDAR_FIELD");
    }
    if (fIntervalPatternsReadOnly) {
        fIntervalPatterns = cloneIntervalPatterns(fIntervalPatterns);
        fIntervalPatternsReadOnly = false;
    }
    PatternInfo ptnInfo = setIntervalPatternInternally(skeleton,
                      CALENDAR_FIELD_TO_PATTERN_LETTER[lrgDiffCalUnit],
                      intervalPattern);
    if ( lrgDiffCalUnit == Calendar.HOUR_OF_DAY ) {
        setIntervalPattern(skeleton,
                           CALENDAR_FIELD_TO_PATTERN_LETTER[Calendar.AM_PM],
                           ptnInfo);
        setIntervalPattern(skeleton,
                           CALENDAR_FIELD_TO_PATTERN_LETTER[Calendar.HOUR],
                           ptnInfo);
    } else if ( lrgDiffCalUnit == Calendar.DAY_OF_MONTH ||
                lrgDiffCalUnit == Calendar.DAY_OF_WEEK ) {
        setIntervalPattern(skeleton,
                           CALENDAR_FIELD_TO_PATTERN_LETTER[Calendar.DATE],
                           ptnInfo);
    }
}