List of usage examples for android.text.format DateUtils FORMAT_ABBREV_ALL
int FORMAT_ABBREV_ALL
To view the source code for android.text.format DateUtils FORMAT_ABBREV_ALL.
Click Source Link
From source file:com.android.mms.ui.MessageUtils.java
public static String formatTimeStampStringExtend(Context context, long when) { Time then = new Time(); then.set(when);//w w w .j a v a 2 s .c o m Time now = new Time(); now.setToNow(); // Basic settings for formatDateTime() we want for all cases. int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; // If the message is from a different year, show the date and year. if (then.year != now.year) { format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { // If it is from a different day than today, show only the date. if ((now.yearDay - then.yearDay) == 1) { return context.getString(R.string.str_ipmsg_yesterday); } else { format_flags |= DateUtils.FORMAT_SHOW_DATE; } } else if ((now.toMillis(false) - then.toMillis(false)) < 60000) { return context.getString(R.string.time_now); } else { // Otherwise, if the message is from today, show the time. format_flags |= DateUtils.FORMAT_SHOW_TIME; } sOpMessageUtilsExt.formatTimeStampStringExtend(context, when, format_flags); return DateUtils.formatDateTime(context, when, format_flags); }
From source file:com.android.mms.ui.MessageUtils.java
public static String getTimeDividerString(Context context, long when) { Time then = new Time(); then.set(when);/*from ww w . ja v a 2s. com*/ Time now = new Time(); now.setToNow(); // Basic settings for formatDateTime() we want for all cases. int formatFlags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; // If the message is from a different year, show the date and year. if (then.year != now.year) { formatFlags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { // If it is from a different day than today, show only the date. formatFlags |= DateUtils.FORMAT_SHOW_DATE; Date curDate = new Date(); Date cur = new Date(curDate.getYear(), curDate.getMonth(), curDate.getDate(), 0, 0, 0); long oneDay = 24 * 60 * 60 * 1000; long elapsedTime = cur.getTime() - when; if (elapsedTime < oneDay && elapsedTime > 0) { return context.getResources().getString(R.string.str_ipmsg_yesterday); } } else { return context.getString(R.string.str_ipmsg_today); } return DateUtils.formatDateTime(context, when, formatFlags); }
From source file:cgeo.geocaching.cgBase.java
/** * Generate a numeric date and time string according to system-wide settings (locale, * date format) such as "7 sept. 12:35". * * @param context/*from w w w . ja va 2s . c o m*/ * a Context * @param date * milliseconds since the epoch * @return the formatted string */ public static String formatShortDateTime(Context context, long date) { return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_ABBREV_ALL); }