本文整理汇总了Java中android.text.format.DateUtils.FORMAT_SHOW_YEAR属性的典型用法代码示例。如果您正苦于以下问题:Java DateUtils.FORMAT_SHOW_YEAR属性的具体用法?Java DateUtils.FORMAT_SHOW_YEAR怎么用?Java DateUtils.FORMAT_SHOW_YEAR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.text.format.DateUtils
的用法示例。
在下文中一共展示了DateUtils.FORMAT_SHOW_YEAR属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFolderStatus
private String buildFolderStatus(FolderInfoHolder folder) {
String folderStatus;
if (folder.loading) {
folderStatus = getString(R.string.status_loading);
} else if (folder.status != null) {
folderStatus = folder.status;
} else if (folder.lastChecked != 0) {
long now = System.currentTimeMillis();
int flags = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
CharSequence formattedDate;
if (Math.abs(now - folder.lastChecked) > DateUtils.WEEK_IN_MILLIS) {
formattedDate = getString(R.string.preposition_for_date,
DateUtils.formatDateTime(context, folder.lastChecked, flags));
} else {
formattedDate = DateUtils.getRelativeTimeSpanString(folder.lastChecked,
now, DateUtils.MINUTE_IN_MILLIS, flags);
}
folderStatus = getString(folder.pushActive
? R.string.last_refresh_time_format_with_push
: R.string.last_refresh_time_format,
formattedDate);
} else {
folderStatus = null;
}
return folderStatus;
}
示例2: formatTime
public static String formatTime(Context context, long when) {
// TODO: DateUtils should make this easier
Time then = new Time();
then.set(when);
Time now = new Time();
now.setToNow();
int flags = DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL;
if (then.year != now.year) {
flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
} else if (then.yearDay != now.yearDay) {
flags |= DateUtils.FORMAT_SHOW_DATE;
} else {
flags |= DateUtils.FORMAT_SHOW_TIME;
}
return DateUtils.formatDateTime(context, when, flags);
}
示例3: dispatchPopulateAccessibilityEvent
/**
* Announce the currently-selected date when launched.
*/
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
// Clear the event's current text so that only the current date will
// be spoken.
event.getText().clear();
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR
| DateUtils.FORMAT_SHOW_WEEKDAY;
String dateString = DateUtils.formatDateTime(getContext(),
mDateMillis, flags);
event.getText().add(dateString);
return true;
}
return super.dispatchPopulateAccessibilityEvent(event);
}
示例4: onCurrentDateChanged
private void onCurrentDateChanged(boolean announce) {
if (mHeaderYear == null) {
// Abort, we haven't initialized yet. This method will get called
// again later after everything has been set up.
return;
}
final String year = mYearFormat.format(mCurrentDate.getTime());
mHeaderYear.setText(year);
final String monthDay = mMonthDayFormat.format(mCurrentDate.getTime());
mHeaderMonthDay.setText(monthDay);
// TODO: This should use live regions.
if (announce) {
final long millis = mCurrentDate.getTimeInMillis();
final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
final String fullDateText = DateUtils.formatDateTime(mContext, millis, flags);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mAnimator.announceForAccessibility(fullDateText); // FIXME we need this on pre-16 devices
}
}
}
示例5: dispatchPopulateAccessibilityEvent
/**
* Announce the currently-selected date when launched.
*/
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
// Clear the event's current text so that only the current date will be spoken.
event.getText().clear();
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR |
DateUtils.FORMAT_SHOW_WEEKDAY;
String dateString = DateUtils.formatDateTime(getContext(), mDateMillis, flags);
event.getText().add(dateString);
return true;
}
return super.dispatchPopulateAccessibilityEvent(event);
}
示例6: updateDisplay
private void updateDisplay(boolean announce) {
/*if (mDayOfWeekView != null) {
mDayOfWeekView.setText(mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG,
Locale.getDefault()).toUpperCase(Locale.getDefault()));
}
mSelectedMonthTextView.setText(mCalendar.getDisplayName(Calendar.MONTH, Calendar.SHORT,
Locale.getDefault()).toUpperCase(Locale.getDefault()));*/
if (this.mDayOfWeekView != null){
this.mCalendar.setFirstDayOfWeek(mWeekStart);
this.mDayOfWeekView.setText(mDateFormatSymbols.getWeekdays()[this.mCalendar.get(Calendar.DAY_OF_WEEK)].toUpperCase(Locale.getDefault()));
}
this.mSelectedMonthTextView.setText(mDateFormatSymbols.getMonths()[this.mCalendar.get(Calendar.MONTH)].toUpperCase(Locale.getDefault()));
mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));
// Accessibility.
long millis = mCalendar.getTimeInMillis();
mAnimator.setDateMillis(millis);
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags);
mMonthAndDayView.setContentDescription(monthAndDayText);
if (announce) {
flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags);
Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
}
}
示例7: getMonthAndYearString
private String getMonthAndYearString() {
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NO_MONTH_DAY;
mStringBuilder.setLength(0);
long millis = mCalendar.getTimeInMillis();
return DateUtils.formatDateRange(getContext(), millis, millis, flags);
}
示例8: getMonthAndYearString
/**
* 获取年份和月份
*
* @return
*/
private String getMonthAndYearString() {
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NO_MONTH_DAY;
mStringBuilder.setLength(0);
long millis = mCalendar.getTimeInMillis();
return DateUtils.formatDateRange(getContext(), millis, millis, flags);
}
示例9: updateDisplay
private void updateDisplay(boolean announce) {
mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));
if (mVersion == Version.VERSION_1) {
if (mDatePickerHeaderView != null) {
if (mTitle != null)
mDatePickerHeaderView.setText(mTitle.toUpperCase(Locale.getDefault()));
else {
mDatePickerHeaderView.setText(mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG,
Locale.getDefault()).toUpperCase(Locale.getDefault()));
}
}
mSelectedMonthTextView.setText(MONTH_FORMAT.format(mCalendar.getTime()));
mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
}
if (mVersion == Version.VERSION_2) {
mSelectedDayTextView.setText(VERSION_2_FORMAT.format(mCalendar.getTime()));
if (mTitle != null)
mDatePickerHeaderView.setText(mTitle.toUpperCase(Locale.getDefault()));
else
mDatePickerHeaderView.setVisibility(View.GONE);
}
// Accessibility.
long millis = mCalendar.getTimeInMillis();
mAnimator.setDateMillis(millis);
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags);
mMonthAndDayView.setContentDescription(monthAndDayText);
if (announce) {
flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags);
Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
}
}
示例10: getMonthAndYearString
private String getMonthAndYearString() {
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR
| DateUtils.FORMAT_NO_MONTH_DAY;
mStringBuilder.setLength(0);
long millis = mCalendar.getTimeInMillis();
return DateUtils.formatDateRange(getContext(), millis, millis, flags);
}
示例11: getMonthAndYearString
private String getMonthAndYearString() {
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NO_MONTH_DAY;
mStringBuilder.setLength(0);
long millis = mCalendar.getTimeInMillis();
return DateUtils.formatDateRange(getContext(), millis, millis, flags); // 지역화된 포멧으로 출력
}
示例12: onPopulateAccessibilityEvent
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
String selectedDateUtterance = DateUtils.formatDateTime(mContext,
mCurrentDate.getTimeInMillis(), flags);
event.getText().add(selectedDateUtterance);
}
示例13: updateDisplay
private void updateDisplay(boolean announce) {
/*
* if (mDayOfWeekView != null) {
* mDayOfWeekView.setText(mCalendar.getDisplayName(Calendar.DAY_OF_WEEK,
* Calendar.LONG,
* Locale.getDefault()).toUpperCase(Locale.getDefault())); }
*
* mSelectedMonthTextView.setText(mCalendar.getDisplayName(Calendar.MONTH
* , Calendar.SHORT,
* Locale.getDefault()).toUpperCase(Locale.getDefault()));
*/
if (this.mDayOfWeekView != null) {
this.mCalendar.setFirstDayOfWeek(mWeekStart);
this.mDayOfWeekView
.setText(mDateFormatSymbols.getWeekdays()[this.mCalendar
.get(Calendar.DAY_OF_WEEK)].toUpperCase(Locale
.getDefault()));
}
this.mSelectedMonthTextView
.setText(mDateFormatSymbols.getMonths()[this.mCalendar
.get(Calendar.MONTH)].toUpperCase(Locale.getDefault()));
mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));
// Accessibility.
long millis = mCalendar.getTimeInMillis();
mAnimator.setDateMillis(millis);
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
String monthAndDayText = DateUtils.formatDateTime(getActivity(),
millis, flags);
mMonthAndDayView.setContentDescription(monthAndDayText);
if (announce) {
flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
String fullDateText = DateUtils.formatDateTime(getActivity(),
millis, flags);
Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
}
}