本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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 "";
}
示例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);
}
}
示例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;
}