当前位置: 首页>>代码示例>>Java>>正文


Java Calendar.DAY_OF_WEEK属性代码示例

本文整理汇总了Java中java.util.Calendar.DAY_OF_WEEK属性的典型用法代码示例。如果您正苦于以下问题:Java Calendar.DAY_OF_WEEK属性的具体用法?Java Calendar.DAY_OF_WEEK怎么用?Java Calendar.DAY_OF_WEEK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.util.Calendar的用法示例。


在下文中一共展示了Calendar.DAY_OF_WEEK属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDisplayNameArray

private static String[] getDisplayNameArray(int field, boolean isLong, Locale locale) {
    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    switch (field) {
        case Calendar.AM_PM:
            return dfs.getAmPmStrings();
        case Calendar.DAY_OF_WEEK:
            return isLong ? dfs.getWeekdays() : dfs.getShortWeekdays();
        case Calendar.ERA:
            return dfs.getEras();
        case Calendar.MONTH:
            return isLong ? dfs.getMonths() : dfs.getShortMonths();
    }
    return null;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:14,代码来源:FastDateParser.java

示例2: isDayDisabledByCriteria

public static boolean isDayDisabledByCriteria(Day day, DisabledDaysCriteria criteria) {
    int field = -1;
    switch (criteria.getCriteriaType()){
        case DAYS_OF_MONTH:
            field = Calendar.DAY_OF_MONTH;
            break;

        case DAYS_OF_WEEK:
            field = Calendar.DAY_OF_WEEK;
            break;
    }

    for(int dayInt : criteria.getDays()){
        if(dayInt == day.getCalendar().get(field)){
            return true;
        }
    }
    return false;
}
 
开发者ID:ApplikeySolutions,项目名称:CosmoCalendar,代码行数:19,代码来源:CalendarUtils.java

示例3: getText

/**
 * Gets the text for the specified chrono, field, locale and style
 * for the purpose of formatting.
 * <p>
 * The text associated with the value is returned.
 * The null return value should be used if there is no applicable text, or
 * if the text would be a numeric representation of the value.
 *
 * @param chrono  the Chronology to get text for, not null
 * @param field  the field to get text for, not null
 * @param value  the field value to get text for, not null
 * @param style  the style to get text for, not null
 * @param locale  the locale to get text for, not null
 * @return the text for the field value, null if no text found
 */
public String getText(Chronology chrono, TemporalField field, long value,
                                TextStyle style, Locale locale) {
    if (chrono == IsoChronology.INSTANCE
            || !(field instanceof ChronoField)) {
        return getText(field, value, style, locale);
    }

    int fieldIndex;
    int fieldValue;
    if (field == ERA) {
        fieldIndex = Calendar.ERA;
        if (chrono == JapaneseChronology.INSTANCE) {
            if (value == -999) {
                fieldValue = 0;
            } else {
                fieldValue = (int) value + 2;
            }
        } else {
            fieldValue = (int) value;
        }
    } else if (field == MONTH_OF_YEAR) {
        fieldIndex = Calendar.MONTH;
        fieldValue = (int) value - 1;
    } else if (field == DAY_OF_WEEK) {
        fieldIndex = Calendar.DAY_OF_WEEK;
        fieldValue = (int) value + 1;
        if (fieldValue > 7) {
            fieldValue = Calendar.SUNDAY;
        }
    } else if (field == AMPM_OF_DAY) {
        fieldIndex = Calendar.AM_PM;
        fieldValue = (int) value;
    } else {
        return null;
    }
    return CalendarDataUtility.retrieveJavaTimeFieldValueName(
            chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:DateTimeTextProvider.java

示例4: getCount

@Override
public int getCount() {
    // Show 5 total pages.
    int mWeekDay = Calendar.DAY_OF_WEEK;
    if ( mWeekDay >= 3) {
        mWeekDay -= 3;
    } else if ( mWeekDay == 2) {
        mWeekDay = 6 - 1;
    } else if ( mWeekDay == 1) {
        mWeekDay = 6 - 2;
    } else if ( mWeekDay == 0) {
        mWeekDay = 6 -3;
    }
    return 5 - mWeekDay;
}
 
开发者ID:mirioeggmann,项目名称:daily-menu-android,代码行数:15,代码来源:MenuPlanActivity.java

示例5: resolveCalendarFieldName

/**
 * Obtains a name of a calendar field with the specified <var>field</var> identifier from the
 * given <var>calendar</var> for the specified <var>locale</var>.
 * <p>
 * <b>Note</b>, that for pre {@link android.os.Build.VERSION_CODES#GINGERBREAD GINGERBREAD} Android
 * version and field names listed below, this method will return only English name regardless
 * the specified <var>locale</var>:
 * <ul>
 * <li>{@link Calendar#MONTH}</li>
 * <li>{@link Calendar#DAY_OF_WEEK}</li>
 * </ul>
 *
 * @param calendar The calendar from which to obtain the requested field's name.
 * @param field    The desired field identifier. See {@link Calendar} for field identifiers.
 * @param style    Style flag for the requested name. One of {@link #CALENDAR_STYLE_SHORT} or
 *                 {@link #CALENDAR_STYLE_LONG}.
 * @param locale   The locale for which to obtain the requested name. If there is no name available
 *                 for the requested locale, {@link UiConfig#DEFAULT_LOCALE} will be used instead.
 * @return Name of the requested calendar field.
 */
@NonNull
@SuppressLint("NewApi")
public static String resolveCalendarFieldName(@NonNull Calendar calendar, int field, int style, @NonNull Locale locale) {
	if (!PRE_GINGERBREAD) {
		final String name = calendar.getDisplayName(field, style, locale);
		return name != null ? name : calendar.getDisplayName(field, style, UiConfig.DEFAULT_LOCALE);
	}
	switch (field) {
		case Calendar.MONTH:
			return PRE_GINGERBREAD_MONTH_NAMES[calendar.get(field)];
		case Calendar.DAY_OF_WEEK:
			return PRE_GINGERBREAD_DAY_NAMES[calendar.get(field) - 1];
	}
	return "";
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:35,代码来源:MonthView.java

示例6: getLunar

/**
     * 获得属性的中文,可以使用的属性字段为DAY_OF_WEEK以及所有农历属性字段。
     * @param field 本类中定义的字段
     * @return 农历日期中文字符串
     */
    public String getLunar(@Field int field) {
        switch (field) {
            case LUNAR_YEAR:
                return getLunar(LUNAR_HEAVENLY_STEM)
                        + getLunar(LUNAR_EARTHLY_BRANCH);

            case LUNAR_MONTH:
                return getLunarMonth(lunarMonth);

            case LUNAR_DATE:
                return lunarDateNames[lunarDate];

            case LUNAR_SECTIONAL_TERM:
                return SolarTerm.getSectionalTermName(get(Calendar.MONTH));

            case LUNAR_PRINCIPLE_TERM:
                return SolarTerm.getPrincipleTermName(get(Calendar.MONTH));

            case LUNAR_HEAVENLY_STEM:
//                if (!areSolarTermsComputed) {
//                    computeSolarTerms();
//                    areSolarTermsComputed = true;
//                }
                return stemNames[get(field)];

            case LUNAR_EARTHLY_BRANCH:
//                if (!areSolarTermsComputed) {
//                    computeSolarTerms();
//                    areSolarTermsComputed = true;
//                }
                return branchNames[get(field)];

            case LUNAR_ANIMAL:
                return animalNames[get(field)];

            case Calendar.DAY_OF_WEEK:
                return lunarWeekNames[get(field)];

            default:
                throw new IllegalArgumentException("Not supported field: " + field);
        }
    }
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:47,代码来源:LunarCalendar.java

示例7: onCreateView

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_menu_plan, container, false);
    Log.i("current weekday: ", String.valueOf(mWeekDay));
    mWeekDay = Calendar.DAY_OF_WEEK;
    if ( mWeekDay >= 3) {
        mWeekDay -= 3;
    } else if ( mWeekDay == 2) {
        mWeekDay = 6 - 1;
    } else if ( mWeekDay == 1) {
        mWeekDay = 6 - 2;
    } else if ( mWeekDay == 0) {
        mWeekDay = 6 -3;
    }
    mMenus = new ArrayList<>();
    mMenuAdapter = new MenuAdapter(R.layout.list_item, mMenus);
    mMenuRecyclerView = (RecyclerView)rootView.findViewById(R.id.menu_recycler_view);
    mMenuRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mMenuRecyclerView.setHasFixedSize(false);
    mMenuRecyclerView.setAdapter(mMenuAdapter);
    //mRestaurantName

    final MenuPlanService menuPlanService = MenuPlanService.retrofit.create(MenuPlanService.class);
    menuPlanService.getMenuPlanByRestaurantAndDay(mRestaurantShortcut,mDay)
            .subscribeOn(Schedulers.newThread())
            .observeOn(AndroidSchedulers.mainThread())
            .map(new Func1<Response<MenuPlan>, MenuPlan>() {
                @Override
                public MenuPlan call(Response<MenuPlan> menuPlanResponse) {
                    return menuPlanResponse.getData();
                }
            })
            .subscribe(new Subscriber<MenuPlan>() {
                @Override
                public void onCompleted() {
                    Log.i("Finished call", "Rx Call is finished");
                }

                @Override
                public void onError(Throwable e) {
                    Log.e("Error", "An error occured", e);
                }

                @Override
                public void onNext(MenuPlan menuPlan) {
                    final TextView menuPlanDateTextView = (TextView) rootView.findViewById(R.id.menu_plan_date);
                    SimpleDateFormat simpleDate =  new SimpleDateFormat("dd.MM.yyyy");
                    menuPlanDateTextView.setText(simpleDate.format(menuPlan.getDate()));
                    final TextView restaurantNameTextView = (TextView) rootView.findViewById(R.id.restaurant_name);
                    restaurantNameTextView.setText(mRestaurantShortcut);
                    mMenus.addAll(menuPlan.getMenus());
                    mMenuAdapter.notifyDataSetChanged();
                }
            });
    return rootView;
}
 
开发者ID:mirioeggmann,项目名称:daily-menu-android,代码行数:57,代码来源:MenuPlanActivity.java


注:本文中的java.util.Calendar.DAY_OF_WEEK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。