List of usage examples for android.text.format DateUtils FORMAT_ABBREV_MONTH
int FORMAT_ABBREV_MONTH
To view the source code for android.text.format DateUtils FORMAT_ABBREV_MONTH.
Click Source Link
From source file:com.google.android.apps.iosched.ui.MyScheduleFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (getActivity() == null || cursor == null) { return;// w ww . j a v a 2 s.c o m } long currentTime = UIUtils.getCurrentTime(getActivity()); int firstNowPosition = ListView.INVALID_POSITION; List<SimpleSectionedListAdapter.Section> sections = new ArrayList<SimpleSectionedListAdapter.Section>(); cursor.moveToFirst(); long previousBlockStart = -1; long blockStart, blockEnd; while (!cursor.isAfterLast()) { blockStart = cursor.getLong(BlocksQuery.BLOCK_START); blockEnd = cursor.getLong(BlocksQuery.BLOCK_END); if (!UIUtils.isSameDay(previousBlockStart, blockStart)) { sections.add(new SimpleSectionedListAdapter.Section(cursor.getPosition(), DateUtils.formatDateTime(getActivity(), blockStart, DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY))); } if (mScrollToNow && firstNowPosition == ListView.INVALID_POSITION // if we're currently in this block, or we're not in a block // and this // block is in the future, then this is the scroll position && ((blockStart < currentTime && currentTime < blockEnd) || blockStart > currentTime)) { firstNowPosition = cursor.getPosition(); } previousBlockStart = blockStart; cursor.moveToNext(); } mScheduleAdapter.changeCursor(cursor); SimpleSectionedListAdapter.Section[] dummy = new SimpleSectionedListAdapter.Section[sections.size()]; mAdapter.setSections(sections.toArray(dummy)); if (mScrollToNow && firstNowPosition != ListView.INVALID_POSITION) { firstNowPosition = mAdapter.positionToSectionedPosition(firstNowPosition); getListView().setSelectionFromTop(firstNowPosition, getResources().getDimensionPixelSize(R.dimen.list_scroll_top_offset)); mScrollToNow = false; } }
From source file:org.openintents.openpgp.util.OpenPgpKeyPreference.java
private void refreshTitleAndSummary() { boolean isConfigured = openPgpApiManager != null && openPgpApiManager.getOpenPgpProviderState() != OpenPgpProviderState.UNCONFIGURED; setEnabled(isConfigured);/*from w ww . j a va2s . c o m*/ if (this.keyId == NO_KEY) { setTitle(R.string.openpgp_key_title); setSummary(R.string.openpgp_no_key_selected); return; } if (this.keyPrimaryUserId != null && this.keyCreationTime != 0) { Context context = getContext(); UserId userId = OpenPgpUtils.splitUserId(keyPrimaryUserId); if (userId.email != null) { setTitle(context.getString(R.string.openpgp_key_using, userId.email)); } else if (userId.name != null) { setTitle(context.getString(R.string.openpgp_key_using, userId.name)); } else { setTitle(R.string.openpgp_key_using_no_name); } String creationTimeStr = DateUtils.formatDateTime(context, keyCreationTime, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_ABBREV_MONTH); setSummary(context.getString(R.string.openpgp_key_created, creationTimeStr)); } else { setTitle(R.string.openpgp_key_title); setSummary(R.string.openpgp_key_selected); } }
From source file:com.conferenceengineer.android.iosched.ui.ScheduleFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (!isAdded()) { return;//w ww . j a v a 2 s . com } Context context = getActivity(); long currentTime = UIUtils.getCurrentTime(getActivity()); int firstNowPosition = ListView.INVALID_POSITION; String displayTimeZone = PrefUtils.getDisplayTimeZone(context).getID(); List<SimpleSectionedListAdapter.Section> sections = new ArrayList<SimpleSectionedListAdapter.Section>(); cursor.moveToFirst(); long previousBlockStart = -1; long blockStart, blockEnd; while (!cursor.isAfterLast()) { blockStart = cursor.getLong(BlocksQuery.BLOCK_START); blockEnd = cursor.getLong(BlocksQuery.BLOCK_END); if (!UIUtils.isSameDayDisplay(previousBlockStart, blockStart, context)) { mBuffer.setLength(0); sections.add( new SimpleSectionedListAdapter.Section(cursor.getPosition(), DateUtils .formatDateRange(context, mFormatter, blockStart, blockStart, DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY, displayTimeZone) .toString())); } if (mScrollToNow && firstNowPosition == ListView.INVALID_POSITION // if we're currently in this block, or we're not in a block // and this block is in the future, then this is the scroll position && ((blockStart < currentTime && currentTime < blockEnd) || blockStart > currentTime)) { firstNowPosition = cursor.getPosition(); } previousBlockStart = blockStart; cursor.moveToNext(); } mScheduleAdapter.swapCursor(cursor); SimpleSectionedListAdapter.Section[] dummy = new SimpleSectionedListAdapter.Section[sections.size()]; mAdapter.setSections(sections.toArray(dummy)); if (mScrollToNow && firstNowPosition != ListView.INVALID_POSITION) { firstNowPosition = mAdapter.positionToSectionedPosition(firstNowPosition); getListView().setSelectionFromTop(firstNowPosition, getResources().getDimensionPixelSize(R.dimen.list_scroll_top_offset)); mScrollToNow = false; } }
From source file:com.android.dialer.calllog.PhoneCallDetailsHelper.java
/** * Get the granular version of the call date. See {@link #getGranularDateTime(PhoneCallDetails)} *///w ww.j a v a 2 s . c o m private String getGranularDate(long date) { if (DateUtils.isToday(date)) { return mResources.getString(R.string.voicemailCallLogToday); } return DateUtils.formatDateTime(mContext, date, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | (shouldShowYear(date) ? DateUtils.FORMAT_SHOW_YEAR : DateUtils.FORMAT_NO_YEAR)); }
From source file:com.philliphsu.bottomsheetpickers.date.BottomSheetDatePickerDialog.java
private static String formatMonthDayYear(Calendar calendar) { int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_YEAR; return formatDateTime(calendar, flags); }
From source file:com.philliphsu.bottomsheetpickers.date.BottomSheetDatePickerDialog.java
private static String formatMonthAndDay(Calendar calendar) { int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_NO_YEAR; return formatDateTime(calendar, flags); }
From source file:com.adguard.android.contentblocker.MainActivity.java
private void refreshStatistics() { PreferencesService preferencesService = ServiceLocator.getInstance(this).getPreferencesService(); final FilterService filterService = ServiceLocator.getInstance(this).getFilterService(); Date now = preferencesService.getLastUpdateCheck(); // Last update time if (now == null) { List<FilterList> filters = filterService.getFilters(); for (FilterList filter : filters) { if (now == null) { now = filter.getTimeUpdated(); LOG.info("Using first time of {}", filter.getName()); } else { if (filter.getTimeUpdated().after(now)) { now = filter.getTimeUpdated(); LOG.info("Using time of {}", filter.getName()); }/*from w w w.j ava 2s. c o m*/ } } if (now == null) { now = new Date(); } } String dateTime = DateUtils.formatDateTime(this, now.getTime(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_TIME); ((TextView) findViewById(R.id.updateTimeTextView)).setText(dateTime); // Enabled filters count int filterListCount = filterService.getEnabledFilterListCount(); ((TextView) findViewById(R.id.filtersCountTextView)).setText(String.format("%d", filterListCount)); // Filter rules count int filterRuleCount = filterService.getFilterRuleCount(); ((TextView) findViewById(R.id.rulesCountTextView)).setText(String.format("%d", filterRuleCount)); if (filterRuleCount == 0) { new ApplyAndRefreshTask(filterService, this).execute(); } }
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
public void updateTitle() { Time start = new Time(mBaseDate); start.normalize(true);// ww w . j ava2s. co m Time end = new Time(start); end.monthDay += mNumDays - 1; // Move it forward one minute so the formatter doesn't lose a day end.minute += 1; end.normalize(true); long formatFlags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR; if (mNumDays != 1) { // Don't show day of the month if for multi-day view formatFlags |= DateUtils.FORMAT_NO_MONTH_DAY; // Abbreviate the month if showing multiple months if (start.month != end.month) { formatFlags |= DateUtils.FORMAT_ABBREV_MONTH; } } mController.sendEvent(this, EventType.UPDATE_TITLE, start, end, null, -1, ViewType.CURRENT, formatFlags, null, null); }
From source file:com.code44.finance.ui.dialogs.recurrencepicker.RecurrencePickerDialogFragment.java
public void updateDialog() { // Interval/*w w w . jav a2 s . c o m*/ // Checking before setting because this causes infinite recursion // in afterTextWatcher final String intervalStr = Integer.toString(mModel.interval); if (!intervalStr.equals(mInterval.getText().toString())) { mInterval.setText(intervalStr); } mFreqSpinner.setSelection(mModel.freq); mWeekGroup.setVisibility(mModel.freq == RecurrenceModel.FREQ_WEEKLY ? View.VISIBLE : View.GONE); mWeekGroup2.setVisibility(mModel.freq == RecurrenceModel.FREQ_WEEKLY ? View.VISIBLE : View.GONE); mMonthGroup.setVisibility(mModel.freq == RecurrenceModel.FREQ_MONTHLY ? View.VISIBLE : View.GONE); mEndGroup.setVisibility(mModel.freq != RecurrenceModel.FREQ_ONCE ? View.VISIBLE : View.GONE); switch (mModel.freq) { case RecurrenceModel.FREQ_ONCE: mIntervalResId = -1; mStartDateResId = R.string.on; break; case RecurrenceModel.FREQ_DAILY: mIntervalResId = R.plurals.recurrence_interval_daily; mStartDateResId = R.string.from; break; case RecurrenceModel.FREQ_WEEKLY: mIntervalResId = R.plurals.recurrence_interval_weekly; for (int i = 0; i < 7; i++) { mWeekByDayButtons[i].setChecked(mModel.weeklyByDayOfWeek[i]); } mStartDateResId = R.string.from; break; case RecurrenceModel.FREQ_MONTHLY: mIntervalResId = R.plurals.recurrence_interval_monthly; if (mModel.monthlyRepeat == RecurrenceModel.MONTHLY_BY_DATE) { mMonthRepeatByRadioGroup.check(R.id.repeatMonthlyByNthDayOfMonth); } else if (mModel.monthlyRepeat == RecurrenceModel.MONTHLY_BY_NTH_DAY_OF_WEEK) { mMonthRepeatByRadioGroup.check(R.id.repeatMonthlyByNthDayOfTheWeek); } if (mMonthRepeatByDayOfWeekStr == null) { if (mModel.monthlyByNthDayOfWeek == 0) { mModel.monthlyByNthDayOfWeek = (mTime.monthDay + 6) / 7; // Since not all months have 5 weeks, we convert 5th NthDayOfWeek to // -1 for last monthly day of the week if (mModel.monthlyByNthDayOfWeek >= FIFTH_WEEK_IN_A_MONTH) { mModel.monthlyByNthDayOfWeek = LAST_NTH_DAY_OF_WEEK; } mModel.monthlyByDayOfWeek = mTime.weekDay; } String[] monthlyByNthDayOfWeekStrs = mMonthRepeatByDayOfWeekStrs[mModel.monthlyByDayOfWeek]; // TODO(psliwowski): Find a better way handle -1 indexes int msgIndex = mModel.monthlyByNthDayOfWeek < 0 ? FIFTH_WEEK_IN_A_MONTH : mModel.monthlyByNthDayOfWeek; mMonthRepeatByDayOfWeekStr = monthlyByNthDayOfWeekStrs[msgIndex - 1]; mRepeatMonthlyByNthDayOfWeek.setText(mMonthRepeatByDayOfWeekStr); } mStartDateResId = R.string.from; break; case RecurrenceModel.FREQ_YEARLY: mIntervalResId = R.plurals.recurrence_interval_yearly; mStartDateResId = R.string.from; break; } updateIntervalText(); updateStartDateText(); updateDoneButtonState(); final String startDateStr = DateUtils.formatDateTime(getActivity(), mModel.startDate.toMillis(false), DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_YEAR); mStartDateTextView.setText(startDateStr); mEndSpinner.setSelection(mModel.end); if (mModel.end == RecurrenceModel.END_BY_DATE) { final String endDateStr = DateUtils.formatDateTime(getActivity(), mModel.endDate.toMillis(false), DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_YEAR); mEndDateTextView.setText(endDateStr); } else { if (mModel.end == RecurrenceModel.END_BY_COUNT) { // Checking before setting because this causes infinite // recursion // in afterTextWatcher final String countStr = Integer.toString(mModel.endCount); if (!countStr.equals(mEndCount.getText().toString())) { mEndCount.setText(countStr); } } } }
From source file:com.tct.mail.ui.ConversationListFragment.java
private String getElapseTime(long time) { long now = System.currentTimeMillis(); long elapseTime = now - time; String displayTime;/*from w ww . j a v a 2 s.c om*/ if (elapseTime < 0) { // abnormal time, this may occur when user change system time to a wrong time displayTime = (String) DateUtils.getRelativeTimeSpanString(mActivity.getActivityContext(), time); } else if (elapseTime < DateUtils.DAY_IN_MILLIS) { //within one day displayTime = (String) DateUtils.getRelativeTimeSpanString(mActivity.getActivityContext(), time); displayTime = mActivity.getActivityContext().getString(R.string.conversation_time_elapse_today) + ", " + displayTime; } else { //beyond one day java.text.DateFormat timeFormat = DateFormat.getTimeFormat(mActivity.getActivityContext()); Date date = new Date(time); String dateText = DateUtils.formatDateTime(mActivity.getActivityContext(), time, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH); displayTime = dateText + ", " + timeFormat.format(date); } return displayTime; }