Java Code Examples for android.text.format.DateUtils#FORMAT_ABBREV_MONTH
The following examples show how to use
android.text.format.DateUtils#FORMAT_ABBREV_MONTH .
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: DateFormatter.java From opentasks with Apache License 2.0 | 6 votes |
public int getDateUtilsFlags(Time now, Time date) { if (now.year == date.year && now.yearDay == date.yearDay) { // today, show time only return FORMAT_SHOW_TIME; } else if (now.year == date.year) { // this year, don't include the year return DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY; } else { return DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY; } }
Example 2
Source File: Utils.java From FireFiles with Apache License 2.0 | 5 votes |
public static String formatDateRange(Context context, long start, long end) { final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH; synchronized (sBuilder) { sBuilder.setLength(0); return DateUtils.formatDateRange(context, sFormatter, start, end, flags, null).toString(); } }
Example 3
Source File: DateFormatter.java From opentasks with Apache License 2.0 | 5 votes |
@Override public int getDateUtilsFlags(Time now, Time date) { int result = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH; if (!date.allDay) { result |= FORMAT_SHOW_TIME; } if (now.year != date.year) { result |= DateUtils.FORMAT_SHOW_YEAR; } return result; }
Example 4
Source File: Utils.java From FireFiles with Apache License 2.0 | 5 votes |
public static String formatDateRange(Context context, long start, long end) { final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH; synchronized (sBuilder) { sBuilder.setLength(0); return DateUtils.formatDateRange(context, sFormatter, start, end, flags, null).toString(); } }
Example 5
Source File: Utils.java From FireFiles with Apache License 2.0 | 5 votes |
public static String formatDateRange(Context context, long start, long end) { final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH; synchronized (sBuilder) { sBuilder.setLength(0); return DateUtils.formatDateRange(context, sFormatter, start, end, flags, null).toString(); } }
Example 6
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
/** * 格式:2018年8月8日 12:40 或者 8月8日 12:40 * * @param date date to show * @return short date and time string */ public static String shortDateTime(Date date) { if (date == null) return ""; Calendar now = Calendar.getInstance(); Calendar c = Calendar.getInstance(); c.setTime(date); int flags = DateUtils.FORMAT_ABBREV_MONTH; if (c.get(Calendar.YEAR) != now.get(Calendar.YEAR)){ flags = flags | DateUtils.FORMAT_SHOW_YEAR; } return DateUtils.formatDateTime(PalmApp.getContext(), date.getTime(), flags) + " " + DateUtils.formatDateTime(PalmApp.getContext(), date.getTime(), DateUtils.FORMAT_SHOW_TIME); }
Example 7
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
public static String getNoMonthDay(Context context, Date date) { if (date == null) return ""; Calendar c = Calendar.getInstance(); c.setTime(date); int flags = DateUtils.FORMAT_ABBREV_MONTH; flags |= DateUtils.FORMAT_NO_MONTH_DAY; flags = flags | DateUtils.FORMAT_SHOW_YEAR; return DateUtils.formatDateTime(context, date.getTime(), flags); }
Example 8
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
public static String getShortDate(Context context, Date date){ if (date == null) return ""; Calendar now = Calendar.getInstance(); Calendar c = Calendar.getInstance(); c.setTime(date); int flags = DateUtils.FORMAT_ABBREV_MONTH; if (c.get(Calendar.YEAR) != now.get(Calendar.YEAR)){ flags = flags | DateUtils.FORMAT_SHOW_YEAR; } return DateUtils.formatDateTime(context, date.getTime(), flags); }
Example 9
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
/** * 获取短的日期,如果指定的日期是今年的,就不用显示年份信息 * * @param context 上下文 * @param calendar 日期 * @return 日期字符串 */ public static String getShortDate(Context context, Calendar calendar){ if (calendar == null) return ""; Calendar now = Calendar.getInstance(); int flags = DateUtils.FORMAT_ABBREV_MONTH; if (calendar.get(Calendar.YEAR) != now.get(Calendar.YEAR)){ flags = flags | DateUtils.FORMAT_SHOW_YEAR; } return DateUtils.formatDateTime(context, calendar.getTime().getTime(), flags); }
Example 10
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
public static String getShortDateWithWeekday(Context context, Calendar calendar) { if (calendar == null) return ""; Calendar now = Calendar.getInstance(); int flags = DateUtils.FORMAT_ABBREV_MONTH; if (calendar.get(Calendar.YEAR) != now.get(Calendar.YEAR)){ flags = flags | DateUtils.FORMAT_SHOW_YEAR; } return DateUtils.formatDateTime(context, calendar.getTime().getTime(), flags) + new SimpleDateFormat(" | E ", Locale.getDefault()).format(calendar.getTime()); }
Example 11
Source File: FormatterUtil.java From social-app-android with Apache License 2.0 | 4 votes |
private static String shortFormatEventDay(Context context, long time) { int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH; Formatter f = new Formatter(new StringBuilder(50), Locale.getDefault()); return DateUtils.formatDateRange(context, f, time, time, flags).toString(); }
Example 12
Source File: FormatterUtil.java From social-app-android with Apache License 2.0 | 4 votes |
private static String shortFormatEventDay(Context context, long time) { int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH; Formatter f = new Formatter(new StringBuilder(50), Locale.getDefault()); return DateUtils.formatDateRange(context, f, time, time, flags).toString(); }
Example 13
Source File: MainActivity.java From samples with MIT License | 4 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { final long min; switch (item.getItemId()) { case R.id.min_0: min = 0l; break; case R.id.min_min: min = DateUtils.MINUTE_IN_MILLIS; break; case R.id.min_hour: min = DateUtils.HOUR_IN_MILLIS; break; case R.id.min_day: min = DateUtils.DAY_IN_MILLIS; break; default: min = -1; break; } if (min >= 0) { item.setChecked(true); mAdapter.setMinResolution(min); return true; } item.setChecked(!item.isChecked()); final int flag; switch (item.getItemId()) { case R.id.FORMAT_SHOW_TIME: flag = DateUtils.FORMAT_SHOW_TIME; break; case R.id.FORMAT_SHOW_WEEKDAY: flag = DateUtils.FORMAT_SHOW_WEEKDAY; break; case R.id.FORMAT_SHOW_YEAR: flag = DateUtils.FORMAT_SHOW_YEAR; break; case R.id.FORMAT_NO_YEAR: flag = DateUtils.FORMAT_NO_YEAR; break; case R.id.FORMAT_SHOW_DATE: flag = DateUtils.FORMAT_SHOW_DATE; break; case R.id.FORMAT_NO_MONTH_DAY: flag = DateUtils.FORMAT_NO_MONTH_DAY; break; case R.id.FORMAT_NO_NOON: flag = DateUtils.FORMAT_NO_NOON; break; case R.id.FORMAT_NO_MIDNIGHT: flag = DateUtils.FORMAT_NO_MIDNIGHT; break; case R.id.FORMAT_ABBREV_TIME: flag = DateUtils.FORMAT_ABBREV_TIME; break; case R.id.FORMAT_ABBREV_WEEKDAY: flag = DateUtils.FORMAT_ABBREV_WEEKDAY; break; case R.id.FORMAT_ABBREV_MONTH: flag = DateUtils.FORMAT_ABBREV_MONTH; break; case R.id.FORMAT_NUMERIC_DATE: flag = DateUtils.FORMAT_NUMERIC_DATE; break; case R.id.FORMAT_ABBREV_RELATIVE: flag = DateUtils.FORMAT_ABBREV_RELATIVE; break; case R.id.FORMAT_ABBREV_ALL: flag = DateUtils.FORMAT_ABBREV_ALL; break; default: throw new UnsupportedOperationException("unknown id"); } if (item.isChecked()) { mAdapter.addFlag(flag); } else { mAdapter.removeFlag(flag); } return true; }
Example 14
Source File: DatePickerDialog.java From BottomSheetPickers with Apache License 2.0 | 4 votes |
private static String formatMonthDayYear(Calendar calendar) { int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_YEAR; return formatDate(calendar, flags); }
Example 15
Source File: DatePickerDialog.java From BottomSheetPickers with Apache License 2.0 | 4 votes |
private static String formatMonthAndDay(Calendar calendar) { int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_NO_YEAR; return formatDate(calendar, flags); }
Example 16
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
public static String getLongDateWithWeekday(Context context, Date date){ int flags = DateUtils.FORMAT_ABBREV_MONTH; flags = flags | DateUtils.FORMAT_SHOW_YEAR; return DateUtils.formatDateTime(context, date.getTime(), flags); }
Example 17
Source File: DateFormatter.java From opentasks with Apache License 2.0 | 2 votes |
@Override public int getDateUtilsFlags(Time now, Time date) { return DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH; }
Example 18
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 2 votes |
/** * 获取长的日期,比如2017年10月10日(后面有日) * * @param context 上下文 * @param date 日期 * @return 日期字符串 */ public static String getLongDate(Context context, Date date){ int flags = DateUtils.FORMAT_ABBREV_MONTH; flags = flags | DateUtils.FORMAT_SHOW_YEAR; return DateUtils.formatDateTime(context, date.getTime(), flags); }